PHP file permissions

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JonGhost
Forum Newbie
Posts: 1
Joined: Tue Oct 21, 2008 5:53 pm

PHP file permissions

Post by JonGhost »

Hey all,
I made a script that creates a file, if it doesn't exist, through fwrite()

The only problem is that when I try writing to this file again later on, it will deny me access. So I have been trying chmod and FTP+chmod to change the permissions on the file to 0666 so I don't run into the access denied error. I can connect and ftp in using the script, but it won't let me chmod the file.

So my problem is that I want to write to a file over and over again in different sessions in different UIDs (kind of like a wiki), but fwrite() keeps returning errors saying that the file is not writable. Is there some fix for this?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP file permissions

Post by requinix »

Just to cover all my bases, you A (when you FTP into your server) and you B (your PHP scripts) are different people. If A creates a file B can't do anything do it. And vice versa.
"Do anything" includes writing and chmod'ing.

Now, fwrite() doesn't normally say "not writable", it says something more specific like "permission denied". Code says that it's not writable.
Speaking of, what's your code?
Post Reply