Reputation: 20212
I try to delete a file which is in /etc/scripts/
First I created a demo file:
echo "test1234" > test.log
-rw-r--r-- 1 root root 5 Jul 3 13:15 test.log
Now I try to delete it by using PHP:
deleteFile();
function deleteFile()
{
$file = "/etc/scripts/test.log";
if (is_file($file)) {
chmod($file, 0777);
if (unlink($file)) {
return "File '$file' deleted.";
} else {
return "File '$file' could not be deleted.";
}
} else {
return "$file is not a file!";
}
}
But I get File '/etc/scripts/test.log' could not be deleted.
as response;
I also executed chmod 777 test.log
on the file, same result.
Upvotes: 1
Views: 68
Reputation: 37028
Not only the file itself, but also the directory /etc/scripts/
should be writable by the user who executes the script.
Upvotes: 3