Jump to content

Php Fopen


trinistorm

Recommended Posts

Does any one know how to change the directory fopen and similar methods operate in?This is my code:

$reader = fopen("counter.txt", "rb");//Opens input stream for the counter file.$flag =  fread($reader, 100);fclose($reader);

However when i change fopen("counter.txt", "rb"); to fopen("C:/sites/counter.txt", "rb"); it still operates only in the folder the program is in.

Link to comment
Share on other sites

Well, I guess that this depends in some way of the configuration of the server. I guess that the server will not allow you to visit files outside its given root dir. this means that if your server has root: "C:/server/httpdir/". You cannot go to: "D:/files/counter.txt" or "C:/programs/counter.txt"

Link to comment
Share on other sites

Ah thanks for your contribution. I found a solution on the php manual website; basically i just use the forward slash and escape it ie: "//" instead of "\"Php websiteThanks again.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...