hi everybody,
I have a function that deletes an image from the database depending on the imageid, but it leaves the file on the server. How can i remove the file at the same time?
public function remove($imageid)
{
$sql = "DELETE FROM images WHERE imageid = $imageid";
$this->db->query($sql);
}
Thanks in advance
André
Assuming $input[“url”] is the physical path to the image file, then yes - it is a start.
But you may also need to consider file/folder permissions - you might need to chmod the file/folder to allow it to be deleted.
Thanks for the pointer anthony. So far i now have:
public function remove($imageid, $input)
{
$url = $input["url"];
unlink($url);
$sql = "DELETE FROM images WHERE imageid = $imageid";
$this->db->query($sql);
}
This looking in the right direction?