Jump to content

Reading text from a php file


Orionsbelter

Recommended Posts

 

$tracking_file_location    =  "../dispatch-manager/logs/tracking_file.txt";
$tracking_file                 =  fopen("$tracking_file_location", "r") or die("Unable to open file!");
$tracking_file_size        =  filesize("$tracking_file_location");
$tracking_file_text        =  fread($tracking_file,$tracking_file_size);
fclose($tracking_file);
Link to comment
Share on other sites

Apologise, for some reason my text hasn't posted. 

 

 

$tracking_file_location    =  "../dispatch-manager/logs/tracking_file.txt";
$tracking_file                 =  fopen($tracking_file_location, "r") or die("Unable to open file!");
$tracking_file_size        =  filesize($tracking_file_location);
$tracking_file_text        =  fread($tracking_file,$tracking_file_size);
fclose($tracking_file);
 
Link to comment
Share on other sites

How would we know why the file is in another directory? We are not sat beside you. 

 

It would be helpful if could actually explain what it is you are trying to do. Just posting a few lines of code is not going to yield you any helpful replies. Also if you are getting any error messages post them in full.

Link to comment
Share on other sites

Specify the exact path to the file:

 

$tracking_file_location    =  "/home/www/exact/path/to/dispatch-manager/logs/tracking_file.txt";

 

Relative file paths will always cause problems. Especially, if the current file is included in a file that is located in a different location.

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.