I used a unlink method to delete the image
This image is located in this file folder only.
$filename = "warning-icon.jpg";
if (file_exists($filename)) {
unlink($filename);
echo 'File '.$filename.' has been deleted';
} else {
echo 'Could not delete '.$filename.', file does not exist';
}
But the image is not deleted.
i have a server name called web04 that is my default server name (Client server name). I can't delete the images from the folder in this server. Same code i have checked in my system localhost, here image get deleted. But in web04 server, Image not get deleted.
Please help me. Thanks in Advance.
define root directory:
$root_directory = '/home/myuser/htdocs';
Now delete the file:
if(unlink($root_directory.$_GET['file']))
echo "File Deleted.";
else
echo "Couldn't delete the File.";
As echo displayed "File name has deleted" and file still in directory, there are maybe another reasons like:
Looks like unlink really delete file as you make "file_exists" check. Maybe try another check?
$filename = "warning-icon.jpg";
if (file_exists($filename)) {
unlink($filename);
echo 'File '.$filename.' has been deleted';
if (file_exists($filename)) {
echo "still exists!!!";
}
} else {
echo 'Could not delete '.$filename.', file does not exist';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With