arunpatal Posted November 18, 2012 Share Posted November 18, 2012 I have a image in images folder . the name of this image file is same as img1 field in database. I want if this field is deleted then the image also delete automatically. How can i do this????? This code is not working for me $picdelete = ("../images/$img1.jpg"); if (file_exists($picdelete)) { unlink($picdelete); } Link to comment https://forums.phpfreaks.com/topic/270847-deleteing-image/ Share on other sites More sharing options...
requinix Posted November 18, 2012 Share Posted November 18, 2012 "Not working" how? Do you get any error messages? Are error_reporting and display_errors set appropriately, or are you looking at error logs? Have you tried debugging this yourself first? What is the exact value of $img1? Are you sure $picdelete is the correct path to the image? How about using an absolute path, constructed using __DIR__ or $_SERVER["DOCUMENT_ROOT"]? Link to comment https://forums.phpfreaks.com/topic/270847-deleteing-image/#findComment-1393319 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.