arunpatal Posted November 18, 2012 Share Posted November 18, 2012 (edited) 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); } Edited November 18, 2012 by arunpatal Quote 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"]? Quote Link to comment https://forums.phpfreaks.com/topic/270847-deleteing-image/#findComment-1393319 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.