Level 75
I use this, here I delete a record and an associated image file, works on shared hosting for me.
function delete()
{
if ($this->chklog() == 'notlogged') {
Url::redirect('admin');
}
$id = $_GET['id'];
$this->Dog->delete($id);
$dfile = "NO File";
if (!empty($_GET['tmppic'])) {
$tmppic = $_GET['tmppic'];
$target_path = ROOT . 'upload/imgdogs/';
$tmpfile = $target_path . $tmppic;
if (is_file($tmpfile)) {
if (!unlink($tmpfile)) {
$dfile = "Error deleting file";
} else {
$dfile = "File deleted";
}
}
}
$data["msg"] = $dfile;
$path = 'dog/imgdel';
View::render($path, $data);
}
Adjust to laravel version you use as needed.