Reputation: 985
I have a table that store the ADDRESS of uploaded files. e. g. "upload/news/pic1.jpg" .
Now my question is:
How can I delete these uploaded files after deleting rows from table. Is there a way to do this automatically? I can't let them stay on host permanently!
thanks...
Upvotes: 0
Views: 35
Reputation: 13283
Go through the file names and delete the files.
foreach ($files as $filepath) {
unlink('/path/to/root/'.$filepath);
}
Then delete the file names from the database.
Computers are stupid. They will only do something if you tell them to do it.
Upvotes: 1