Ways to create files on Apache Server from a php file

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
hsuoahpainng
Forum Newbie
Posts: 2
Joined: Thu Jan 13, 2011 10:24 pm

Ways to create files on Apache Server from a php file

Post by hsuoahpainng »

Hi everybody,

I'm a pretty new guy/woman at Php. I need to create a XML file to store data on the server. The server is a hosting Apache Linux server.

However, I guess because of the security issues, the php file cannot save the created XML file on the server. I used "$xml = new DOMDocument()" method, then create elements, append to the file, and use "$xml->save("test.xml")" to try to save the xml file generated. It works perfectly fine on my local machine (WAMP), yet, failed to work on the remote hosting server.

How to overwrite security issues and able to save the xml file on the server from the Php program running on the server? Please shed some lights if you can... This seems to be the bottleneck of my current project

Thanks a lot for any suggestions

Maggie
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Ways to create files on Apache Server from a php file

Post by pickle »

It's likely a permissions issue - the Apache user doesn't have write permissions to the directory in which you're trying to create the directory.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

Re: Ways to create files on Apache Server from a php file

Post by Peter Kelly »

Generally you need to login with either your FTP or File Manager and check the permissions of the location in which you want the file saved/created. To save/create you need to set them to 777 *If anyone else knows the specific ones for specifically file write please comment this was just off the top of my head*. You should be cautious though as open folders like this can be used maliciously so I would make sure you lock down the permissions as much as possible.
Post Reply