Jump to content

Filesystem path issues


akitchin

Recommended Posts

hey there,

 

i often define a system path variable with the filesystem-based path to the current working directory, like so:

 

define('SYS_PATH', '/projects/somedir/somesubdir');

 

where projects is a directory immediately below the directory set as my localhost.  this works on *nix machines, but the path seems to trump any windows machines with a "The file cannot be found" error:

 

require_once(SYS_PATH.'/includes/something.php');

 

the path echoed in the error is exactly the path to the file, and the file is there.  furthermore, the filesystem path in the $_SERVER array is the one i use in SYS_PATH, so i see no reason why it should work on *nix but not windows.

 

anyone know of some discrepancies between directory handling?  all server settings are the same, the only difference being in the OS.  i'd appreciate any help, since this makes local testing utterly useless.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...

its hard to tell because we dont know the dir we use that style i our site but maybe all i can say is that you echo the full path in the include to see where you went wrong if you can do that without using the define then it has no diff with define

Link to comment
Share on other sites

I think on windows the working dir is stored with a "/" at the end. it should work if you take the "/" off the beginning of your path.

define('SYS_PATH', 'projects/somedir/somesubdir');

 

You might even need to put a "/" at the end of it too, in some cases, I'm not sure.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.