Jen Posted August 14, 2006 Share Posted August 14, 2006 I wrote a very simple script that was supposed to update the contents of a news.txt file on the server's system, but I got "permission denied" errors when the script was run on the server. I searched this forum for answers and found a lot about chmod, which I now understand has to do with file access permissions. What I need is a clear explanation to a php noob about what chmod does, what's the significance of the number parameters (i.e. 755), and which number I should chmod to in my case. Thanks! Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 14, 2006 Share Posted August 14, 2006 http://webmasterworkshop.com/guides/chmod_guide.shtmlThat should explain all Quote Link to comment Share on other sites More sharing options...
Jen Posted August 14, 2006 Author Share Posted August 14, 2006 Thanks, the link explained a lot. However, I have more questions. Could anyone explain in more detail who falls into the "group" category as explained in the linked page? Also, I want certain pages on my site to be password protected by a simple method which checks the user-entered password against the one on file. Currently, anyone can view the contents of this file to find out the password. Should I use 722 for the permission setting for that file? If I chmod this file once, will it stay that way forever, or will I have to include a chmod somewhere in all my scripts to make sure that the file's permission settings stay like that? Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 14, 2006 Share Posted August 14, 2006 a file retains its permissions until intentionally changed Quote Link to comment Share on other sites More sharing options...
Jen Posted August 14, 2006 Author Share Posted August 14, 2006 OK, well I just stuck a short script on the server and ran it to try and change the permission of the news file I'm writing to, and I got an error saying i'm not the owner, so the chmod failed. What can I do now? Here's the script:<?phpchmod("news.txt", 722);?> Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 14, 2006 Share Posted August 14, 2006 http://ca.php.net/manual/en/function.chmod.php - try chmod 0722 not chmod 722http://ca.php.net/manual/en/function.chown.php - be careful about changing owners Quote Link to comment Share on other sites More sharing options...
Jen Posted August 14, 2006 Author Share Posted August 14, 2006 Is there a way to find out who the owner is, or what the current file permission settings are for a particular file? If I use chown, what exactly becomes the owner? Is it the file that runs the script with chown("filename", "root")? And what is the value of "root"? I'm looking at Tayfun's post: http://ca.php.net/manual/en/function.chown.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.