Jump to content

Archived

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

herando

how to delete files?

Recommended Posts

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'";

Share this post


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

Share this post


Link to post
Share on other sites
[!--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";
}

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.