Jump to content

get_file_contents does not work with existing local files


techdude

Recommended Posts

Hi.

 

I have php code that attempts to read a file into a string using get_file_contents(), but it claims the file does not exist. I do the same thing in another php file (same directory) and it works. Only difference is that the first file has the call in a function.

 

File one:

$email_template = "../email_templates/new_instructor.html";

echo file_exists($email_template);

$message = file_get_contents($email_template);//get the email template

 

File two:

	$email_template = "../email_templates/new_instructor.html";

echo file_exists($email_template);

echo file_get_contents($email_file);

 

plz help.'

thanx

Only difference is that the first file has the call in a function.

 

^^^ You would need to post actual code that demonstrates/reproduces the problem.

 

Posting two partial snippets of code, taken out of context of where they work and where they don't, without even identifying which one is which, doesn't help.

The code was

 

error_reporting(E_ALL);
ini_set('display_errors', '1');

file_get_contents("Auth.php");

 

The include_dir contained the /usr/share/pear folder.

 

Found the solution, it was blocked by an open_basedir path, but because it was an include without a path, it DID NOT PRODUCE THE USUAL ERROR THAT "Open basedir restriction was in effect". Kind of a wierd effect, but it worked to add that file to the open base dir. I wonder why it fails silently.

 

--

techdude

Archived

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

×
×
  • 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.