Jump to content

[SOLVED] unlink file error


brem13

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.

 

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.