Jump to content

PHP Relative links not working


beh

Recommended Posts

Hi Everyone,

 

Quick questions. I've recently installed the latest version of PHP running on IIS 6 (XP Pro). When running the following the following code:

 

	function getFile($vFile)
{
	if (function_exists('file_get_contents'))
    	{
      		$vString = @file_get_contents ($vFile);

	}
	else
	{
		$vString = implode('', @file($vFile));
	}

	if (!$vString)
	{
		echo "[$vFile] does not exist.";
		exit;
	}
	else return $vString;
}

 

When $vFile is a relative path it fails. When using an absolute path it works fine. This is consistent across all file commands including is_file etc.

 

Can anyone help? I presume that this is something to do with an ini setting or iis?

 

Regards,

 

Paul

 

Link to comment
Share on other sites

You would need to give an example of a link that works and one that does not work. It is likely you are writing it incorrectly.

 

Are you trying relative file system paths or URL's? A file system path is relative to the current working directly of the main script that is running. Using a URL in php function that normally operates on file system paths, requires a fully qualified URL (http://domain/path/file)

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.