spelltwister Posted August 20, 2006 Share Posted August 20, 2006 Hi all,I have a script that writes files to my server:[code]$data = "<?xml version=\"1.0\"?>\n"; $data .= "<units>\n";...$data .="</units>";$file = "/path.xml"; if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; } if (!fwrite($file_handle, $data)) { echo "Cannot write to file"; } fclose($file_handle);[/code]the problem is that it only writes the files when the server runs a cron job. Otherwise, it can't run them. I know the problem is folder permissions, however I'm not sure how to set them to get this result:1. I do not want to make the folder writable from everywhere2. I want to be able to accept an xml file upload and write to the serverIs there a way to "login" as the server or add something to my script that will allow it to write to the server and no one else?Thanks,Mike Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 20, 2006 Share Posted August 20, 2006 Are you using Windows or *nix? Apache or IIS? Quote Link to comment Share on other sites More sharing options...
spelltwister Posted August 20, 2006 Author Share Posted August 20, 2006 I have a remote host and it's using, I believe, Unix and Apache. I'll find out for sure when I can get a hold of them. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 20, 2006 Share Posted August 20, 2006 I think if you do a chmod to 744 on the directory it will enable read/write/execute for the owner, and read only for all others. Quote Link to comment Share on other sites More sharing options...
spelltwister Posted August 20, 2006 Author Share Posted August 20, 2006 owner is already r/w/e. Here's two example of what I want: I go to a page, fill out a form, hit submit and i want to generate xml files. (if this has to be full write access on the folder, I'll figure something else out).Secondly: I upload an xml file to a page, it parses it, runs calcs, etc, and then writes another one. Is this able to be done with just owner r/w/e?Thanks Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted August 20, 2006 Share Posted August 20, 2006 In order to write a file to a directory, the directory has to have write access enabled for the user that is writing to it. Generally, if the web server is writing, then you can get away with either 744 or 764, depending on how the groups are set up, if at all.Try setting up the permissions as 764 or 777 and reducing them until you are no longer able to achieve what you want, then decide if that is too high for your comfort. Quote Link to comment Share on other sites More sharing options...
spelltwister Posted August 20, 2006 Author Share Posted August 20, 2006 can you please say what groups are?Also, is there a way that in the script i can make it as thought the webserver is doing the writing. I know that the only way to wirte right now is 777 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.