Jump to content

Php Fopen


trinistorm
 Share

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.

Edited by sansana
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...