Jump to content

Write to server


spelltwister

Recommended Posts

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 everywhere
2.  I want to be able to accept an xml file upload and write to the server

Is 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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.