Jump to content

No Such File Or Directory


ShadowMage

Recommended Posts

Hi,I have a problem with a script I'm trying to access using AJAX. I'm trying to include another file in the script for the AJAX, but I keep getting errors saying there's no such file or directory. If I use an absolute path instead of a relative path it works.The AJAX script is located in this directory: C:\Inetpub\major\SkyPrice\Scripts\AJAX_Requests\CreateSkylight.phpThe file I'm trying to include is located here: C:\Inetpub\major\SkyPrice\Classes\WallPanel.phpHere are my include lines:

require_once('/SkyPrice/Classes/WallPanel.php');//This one works but I'd rather use a relative path//require_once("C:\\Inetpub\\major\\SkyPrice\\Classes\\WallPanel.php");

Can anyone tell me why this is happening?Thanks,jkloth

Link to comment
Share on other sites

Hi,I have a problem with a script I'm trying to access using AJAX. I'm trying to include another file in the script for the AJAX, but I keep getting errors saying there's no such file or directory. If I use an absolute path instead of a relative path it works.The AJAX script is located in this directory: C:\Inetpub\major\SkyPrice\Scripts\AJAX_Requests\CreateSkylight.phpThe file I'm trying to include is located here: C:\Inetpub\major\SkyPrice\Classes\WallPanel.phpHere are my include lines:
require_once('/SkyPrice/Classes/WallPanel.php');//This one works but I'd rather use a relative path//require_once("C:\\Inetpub\\major\\SkyPrice\\Classes\\WallPanel.php");

Can anyone tell me why this is happening?Thanks,jkloth

Try
require_once('../../SkyPrice/Classes/WallPanel.php');

or

require_once('../../../SkyPrice/Classes/WallPanel.php');

Link to comment
Share on other sites

The leading slash makes this one an absolute path:require_once('/SkyPrice/Classes/WallPanel.php');
Well yes, that's true. I guess what I meant to say was hard coded. I use this exact statement in another script and it works properly. This should work though shouldn't it? All of my script files are in the SkyPrice directory.
Try
require_once('../../SkyPrice/Classes/WallPanel.php');

or

require_once('../../../SkyPrice/Classes/WallPanel.php');

Tried this, neither one works. Tried double dots and single dots. I believe proper syntax is single dots, since they work in other locations in my scripts.
Link to comment
Share on other sites

Well yes, that's true. I guess what I meant to say was hard coded. I use this exact statement in another script and it works properly. This should work though shouldn't it? All of my script files are in the SkyPrice directory.
Then just remove the first slash.
require_once('SkyPrice/Classes/WallPanel.php');

Link to comment
Share on other sites

A single dot references the current directory, two dots reference the parent directory. Since the path to require is usually seen as a local path instead of an HTTP path, beginning the path with a slash on a Linux server tells it to look in the root of the filesystem, it's the same thing as beginning a path on Windows with C: or another drive letter.If you're trying to include this:C:\Inetpub\major\SkyPrice\Classes\WallPanel.phpfrom this:C:\Inetpub\major\SkyPrice\Scripts\AJAX_Requests\CreateSkylight.phpthen the relative path would be "..\..\Classes\WallPanel.php". You want to go up 2 levels to get to the SkyPrice directory, then down to the file.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...