Page 1 of 1

PHP - Change File Permissions on Linux Server

Posted: Wed Nov 10, 2010 3:30 am
by Ultra
Hi,

I've been reading all over the i-net and could not find a solution to my problem here:

I'm accessing a php script in the backend admin part of my web application VIA WEB BROWSER which tries to delete a file.

I get permission denied errors.

I try to change permissions on the file but it won't let me.

Here's my code:

if(is_file($file_path))
{
// change file permissions
chmod($file_path, 0777);

// delete file
if(unlink($file_path))
{
echo "<p>file deleted !</p>";
}
else
{
echo "<p>file NOT deleted !</p>";
}
}
else
{
echo "<p>file does NOT exist !</p>";
}

Current file permissions are 644.

Any idea what I need to do ?

Thanx in advance for your help !

- M

Re: PHP - Change File Permissions on Linux Server

Posted: Wed Nov 10, 2010 3:44 am
by mikemike
Could you give us the specific error you're getting?

Try changing the permissions to 0777 of the file you're deleting (I doubt this will make any difference).

Try changing the permissions of the file you're using to delete to 0777, this is more likely to work.

Failing that it might be a user/group issue, but we can't tell that without a specific error and more details.

Re: PHP - Change File Permissions on Linux Server

Posted: Wed Nov 10, 2010 3:00 pm
by Ultra
mike,

thanx for ypur reply.

I already tried to set the file permission of the file that is trying to delete the .zip file to 0777, does not do the job.

the error the server throws is:

regarding chmod(): "Operation not permitted in ... "

regarding unlink(): "Permission denied in ... "

Thanx.

Re: PHP - Change File Permissions on Linux Server

Posted: Wed Nov 10, 2010 5:17 pm
by VladSun
Who is the owner of the file and directory?