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 Quote Link to comment 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] Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted March 31, 2006 Author Share Posted March 31, 2006 Yup, thank you. Quote Link to comment 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.