문제

This code runs when a user hits a delete button on my form. I am trying to copy a file, $picfile, from "/pics/" to "/pics/deletedrecordpics/" and then delete the orginal. Finally, delete the record from the database. Deleting the record from the databse works, but copying the file and deleting the original does nothing. There are no errors in the error log, so I am really confused as to why this code isn't running as I think it should.

   $sql = ("select picfile,title,author from $table where id=$delete");             
   $file=mysql_query($sql);
   $resrow = mysql_fetch_row($file); 
   $picfile = $resrow[0]; 
   $title = $resrow[1]; 
   $author = $resrow[2];     
   copy("pics/".$picfile,"pics/deletedrecordpics/".$author." - ".$title." - ".$picfile);    
   unlink("pics/".$picfile);
   $sql = ("DELETE FROM $table WHERE id=$delete");
   $result = mysql_query($sql);
도움이 되었습니까?

해결책

To make sure unlink should work check if your permissions are set correctly, and if unlink is available on the server installation.

Copy might not be working if "/deletedrecordpics" is a non existing directory, not created yet.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top