i upload image to the server and save the path in data base. Now i want to delete that record and also the image with that record my code is
$id=$_GET['id']; $select=mysql_query("select image from table_name where question_id='$id'"); $image=mysql_fetch_array($select); @unlink($image['image']); $result=mysql_query("delete from table_name where question_id='$id'");
when i echo $image['image']; this will give me
http://www.example.com/folder/images/image_name.jpegThe record is deleted successfully but the image remains there on server.
You'll have to use the path on your server to delete the image, not the url.
unlink('/var/www/test/folder/images/image_name.jpeg'); // correct
you should remove the @
before unlink()
, in that case you would have seen the error-message saying "file not found" or something like that.
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