Editing files with read-only permissions? Stupid Newbie!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

New php-forum User
New php-forum User
Posts: 1
Joined: Wed May 08, 2013 11:09 am

Editing files with read-only permissions? Stupid Newbie!

Postby Jimbo » Wed May 08, 2013 11:43 am

Hi Guys,
New to the forum and hoping to get into PHP a lot more than I am at present, so your help is VERY appreciated!

I need to use a browser to access and edit a file on a remote server. I want to do it with a simple user interface for novice users, so figured using the browser is simplest.

I have created a PHP script that "fopen"s the file (read mode) and presents the file (fget and then echo the output) to the user to view via their browser. The user can then fill out a text box presented by the browser with the same, more, or less text as the original contents. The script them "fopen"s the file (write mode this time) and "fwrite"s it.

This all works nicely. The problem I have is that the file I want to edit is mode 644, so the php script, which is in the same group and has the same owner, is still unable to edit it. I could open up the permissions on the file I want to edit to 666, but I don't want to blow security like that.

So the Stupid Newbie Question (sorry :( ) is "Is there a way of giving the script root privileges so it CAN edit the 644 file without messing with the target file's permissions....

Yes, I'm very aware it's a stupid question and I should Google, but I HAVE done and I'm no further forward...sorry, I'll get me coat....


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests