Question

I have a txt file that I need to access via fopen that is located at /etc/company/lastID.txt via the following script:

$dataFile = "/etc/company/lastID.txt";
$fh = fopen($dataFile, "r");

print_r(error_get_last());

$lastID = fread($fh, filesize($dataFile));
fclose($fh);

The error I am receiving is:

fopen(/etc/company/lastID.txt): failed to open stream: No such file or directory

but the file is definitely there. When I call another file in the same directory using require_once it is read without issue, only when I use fopen do I seem to have a problem.

Any thoughts?

Was it helpful?

Solution

What's happen when you try to read another file in /etc/company directory? This error means file doesn't exits.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top