I have this code:
$FileName = DIRECTORY_SEPARATOR."public_html".DIRECTORY_SEPARATOR."BushlandRecovery".DIRECTORY_SEPARATOR."JobsList.txt";
$JobsListFile = fopen($FileName,"r");
if ($JobsListFile)
{
No matter what I do with the file name or the directory structure I cannot open the f'ing file. Not in r mode or w mode.
I cannot detect any files with file_exits(...)
There are no specific settings in CPanel that lets me give php read permission etc.
So how do you open a bloody file in php?????
I fail to understand why it needs to be so difficult.
Why is so friggin hard to open files in php?
Moderator: General Moderators
Re: Why is so friggin hard to open files in php?
It isn't terribly difficult. I'm guessing you're running into problems because you're starting with a slash, denoting an absolute path, and /public_html is not a top level directory on any machine I've encountered. $_SERVER['DOCUMENT_ROOT'] will resolve the path to your, well, document root and you can build from there.
$fh = fopen($file_name, 'r');
etc.[/syntax]
Code: Select all
$file_name = $_SERVER['DOCUMENT_ROOT'] . '/BushlandRecovery/JobList.txt';etc.[/syntax]