Jump to content

Archived

This topic is now archived and is closed to further replies.

lpxxfaintxx

Deleting Files

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
[code]$filename = "{relativepath}/{filename}";
unlink($filename);[/code]

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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.