-
File not opening in php
Hi.
I have my home directory on my departments server. Somehow I am not
able to write to a file using a php code,
$myFile = "trial3.txt";
$fh = fopen($myFile, "a+") or die("can't open file");
fwrite($fh, "teststring\n");
fclose($fh);
Instead of a+ if i use r or w or anything, it does not work. Could this
be a permission thing? The entire directory had a 777 permission and
even i after i created a file and chmod'ed 777 to it, the code couldnt
open it. What could be the matter? It doesnt go away if i change it to
'w' or 'w+' or 'r' or 'r+'.
When i use the shell to parse the php script, it does actually write it to the file. But not when i open the url in the browser. What could be the matter?
Rahul
-
-
If I recall correctly fopen requires full path to file to work, unless you set third parameter to true (use_include_path)
-
-
The file also has to be on the remote server you're working on. I don't think using the full path will be any use either, using what I previously said to back it up.
So. Put the file in your remote directory, or folder.
- Mike
-
-
also, make sure that the directory has writable permissions or is at least owned by the same user as the PHP is running on your machine. I've run into this problem tons of times. If the directory was created by PHP, then it should be alright, but if it was not, you may have to chmod the directory to 777. Just a few suggestions.
-
-
Oh yes. Exactly right, I forgot about that. It has to be 555 if made with PHP I'm pretty sure.
- Mike
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks