I'm frustrated about deleting file in ubuntu using PHP unlink().
I created a very simple simulation as follow:
The "image.png" still exists in "files" directory
Here is the php script of delete.php :
$filename = 'image.png';
$file = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . $filename;
unlink($file);
I also tried the following script :
$filename = 'image.png';
$dir = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'files';
chdir($dir);
unlink($filename);
But still can't delete the file.
The folder/owner of the directory could be a different user than the user being used to run php.
You should create a folder with the user php assigned. If you cannot do that yourself ask your ISP to do it. That is how I solved a similar problem.
One user cannot delete files of another user on a unix system. If you would set it to 777 then you could delete it...