Jump to content

Deleteing Image


arunpatal

Recommended Posts

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

"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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.