Jump to content


Photo

Deleting Files


  • Please log in to reply
3 replies to this topic

#1 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 30 March 2006 - 11:14 PM

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

#2 realjumper

realjumper
  • Members
  • PipPipPip
  • Advanced Member
  • 399 posts

Posted 30 March 2006 - 11:21 PM

This is how I do both.....remove from the db and delecte the file from the directory...

$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); 


#3 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 30 March 2006 - 11:23 PM

$filename = "{relativepath}/{filename}";
unlink($filename);

You must make sure you have permissions on the file to remove/modify it.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.


#4 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 31 March 2006 - 12:49 AM

Yup, thank you.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users