I'm frustrated about deleting file in ubuntu using PHP unlink().
I created a very simple simulation as follow:
- create a folder named "files" beneath /var/www with 766 permission.
- upload a file, let say "image.png" in that folder & set the permission into 666
- create a php file named delete.php, set the permission to 644 and upload to /var/www directory
- Call the file in browser (I use localhost)
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.