lpxxfaintxx Posted March 30, 2006 Share Posted March 30, 2006 Is this possible? I have a page 'deleteimages.php' and it deletes the mysql row fine, but how can I make it delete the image also?-Thanks Link to comment https://forums.phpfreaks.com/topic/6220-deleting-files/ Share on other sites More sharing options...
realjumper Posted March 30, 2006 Share Posted March 30, 2006 This is how I do both.....remove from the db and delecte the file from the directory...[code]$id=$_GET['id']; // Retrieve all the data from the table$result = mysql_query("SELECT * FROM uploads WHERE id='$id'") or die(mysql_error()); // store the record of the table into $row$row = mysql_fetch_array( $result );$myFile = "upload_files/$row[userfile]";unlink($myFile);$query = "DELETE FROM uploads WHERE id='$id'"; $result = mysql_query($query); [/code] Link to comment https://forums.phpfreaks.com/topic/6220-deleting-files/#findComment-22472 Share on other sites More sharing options...
txmedic03 Posted March 30, 2006 Share Posted March 30, 2006 [code]$filename = "{relativepath}/{filename}";unlink($filename);[/code]You must make sure you have permissions on the file to remove/modify it. Link to comment https://forums.phpfreaks.com/topic/6220-deleting-files/#findComment-22473 Share on other sites More sharing options...
lpxxfaintxx Posted March 31, 2006 Author Share Posted March 31, 2006 Yup, thank you. Link to comment https://forums.phpfreaks.com/topic/6220-deleting-files/#findComment-22491 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.