herando Posted May 25, 2006 Share Posted May 25, 2006 i choose a file from a form field and upload to folder and write a file name to table. when i delete a row, it deletes only file names from table. how to delete a corresponding file when a row is deleted?row delete line:$sql_del="DELETE FROM $data_table WHERE id='$id'"; Quote Link to comment https://forums.phpfreaks.com/topic/10425-how-to-delete-files/ Share on other sites More sharing options...
wisewood Posted May 25, 2006 Share Posted May 25, 2006 $query = "SELECT * FROM $data_table WHERE id='$id'";$result = mysql_query($query);Set the filename variable with the value from the database, and then use:unset($filename);then delete the entry from the database. Quote Link to comment https://forums.phpfreaks.com/topic/10425-how-to-delete-files/#findComment-38855 Share on other sites More sharing options...
lead2gold Posted May 25, 2006 Share Posted May 25, 2006 [!--quoteo(post=376962:date=May 25 2006, 06:27 AM:name=herando)--][div class=\'quotetop\']QUOTE(herando @ May 25 2006, 06:27 AM) [snapback]376962[/snapback][/div][div class=\'quotemain\'][!--quotec--]i choose a file from a form field and upload to folder and write a file name to table. when i delete a row, it deletes only file names from table. how to delete a corresponding file when a row is deleted?row delete line:$sql_del="DELETE FROM $data_table WHERE id='$id'";[/quote]I think what your looking for is:$filename= "/tmp/test.file";if(!unlink($filename)){ echo "file deleted";}else{ echo "failed to delete file";} Quote Link to comment https://forums.phpfreaks.com/topic/10425-how-to-delete-files/#findComment-38889 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.