Mobile app version of vmapp.org
Login or Join
Alves908

: How do I edit/modify a file on a webserver using php file in the same location? I have an XML file on my server. In the same directory I have a PHP file which modifies the content of the

@Alves908

Posted in: #Authentication #Domains #Server

I have an XML file on my server. In the same directory I have a PHP file which modifies the content of the XML and saves it. In this, the save part doesn't work. In my knowledge the code is alright and the problem is with the file access persmissions.

More details available here: stackoverflow.com/questions/3351652/how-to-save-an-xml-file-on-the-web-server-using-php ( There is nothing wrong with the code. I provided it to give more insights. The problem seems to be with the access permissions )

The permissions of the XML file is: rw-r--r-- (644)

My question is, am I doing it right? How do I modify a file in the same directory?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Alves908

2 Comments

Sorted by latest first Latest Oldest Best

 

@YK1175434

Maybe I'm overlooking something, but it seems like you only have given write access to the owner, which has already been established to be likely something other than your PHP/Webserver's user, thus, no permission to write.

You could either make sure that your user is in the "www-data" group (or whichever group your webserver is using) and add write permission to the group "chmod g+w filename.xml"

Or, you could place that file in the "www-data" group with "chown www-data:www-data filename.xml"

10% popularity Vote Up Vote Down


 

@Gloria169

The answer will change depending on who owns the rights to that file. For example when I create a file on our server with our FTP client (filezilla) the owner is the username of our FTP account but if we create the file using PHP the owner is www-data.

That being said by looking at your rights I see that only the owner has the right to write on your file, the group and other only have read access. Here's a calculator I'll often use to figure which rights to give to the chmod command (http://www.onlineconversion.com/html_chmod_calculator.htm). It's pretty intuitive but I'm guessing you'll have to give write access to the group.

Hope that helps :)

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme