Jump to content


Photo

Write to server


  • Please log in to reply
6 replies to this topic

#1 spelltwister

spelltwister
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 20 August 2006 - 03:58 PM

Hi all,

I have a script that writes files to my server:

$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);

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

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 August 2006 - 04:01 PM

Are you using Windows or *nix?  Apache or IIS?

#3 spelltwister

spelltwister
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 20 August 2006 - 04:13 PM

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.

#4 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 August 2006 - 04:16 PM

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.

#5 spelltwister

spelltwister
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 20 August 2006 - 04:33 PM

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

#6 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 August 2006 - 04:38 PM

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.

#7 spelltwister

spelltwister
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 20 August 2006 - 04:42 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users