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.
rootvar_dump(file_exists($file));first, inside thedeleteFilefunction