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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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.