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);
   }

Edited by arunpatal
Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.