Page 1 of 1

Loading file from root directory

Posted: Tue Mar 07, 2006 2:41 pm
by djwk
Hi

I have tried this:

Code: Select all

$file = "./count.dat";
$fh = fopen($file, 'r');
$count1 = fgets($fh);
fclose($fh);
However the './' does not load the file from the root directory. Basically I have a folder inside the root directory, the php file with the above code in is in that folder, i want to read from a file in the root directory.

Can anyone help?

Posted: Tue Mar 07, 2006 2:43 pm
by feyd
remove the leading dot.

Posted: Tue Mar 07, 2006 2:45 pm
by djwk
If you mean like this '/count.dat' I already tried that

Posted: Tue Mar 07, 2006 2:47 pm
by feyd
That's the way to reference root, so unless you define root differently than, likely, the rest of us, your script may not have the permission to read there.

Posted: Tue Mar 07, 2006 3:00 pm
by djwk
I tried it again and recieved the same error:

Warning: fopen(/count.dat): failed to open stream


I need this to work, how annoying!

Posted: Tue Mar 07, 2006 3:07 pm
by djwk
OHHH! Sorry my idiotic mistake.

I forgot its an addon domain, so its located in another sub folder. I'll try adding the folders to the filename and let you know what happens :)