Jump to content

Recommended Posts

ive got a script that deletes pictures if the checkbox is checked and it works fine, it deletes the picture, the thumbnail and the row from the database, but it still loops through and looks for the picture and since its not there it gives me an unlink..cannot find the file error

 

foreach($aPics as $PicKey => $picname) {

    if(array_key_exists($PicKey, $aComments)) {

       

        if (isset($delete[$PicKey])){

   

        mysql_query("DELETE FROM $userlow WHERE picture='$picname'") or die(mysql_error());

      unlink($picname);

      unlink("thumbs/".$picname);

       

    }//end iff

      }//end foreach

 

 

error: unlink(1234907747.jpg) [function.unlink]: No such file or directory in editgall.php on line 57

 

 

Link to comment
https://forums.phpfreaks.com/topic/148849-solved-unlink-file-error/
Share on other sites

You could check if the file exists before you call unlink.

 

if(file_exists($picname)){
  unlink($picname);
}else{echo 'file not found';}
if(file_exists("thumbs/".$picname)){
  unlink("thumbs/".$picname);
}else{echo 'thumb not found';}

 

If you're getting the echo'd error message, make sure that the path is correct, as well.

 

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.