From 6685a82cd9d0295279e9434a4f23c66f7dc7003c Mon Sep 17 00:00:00 2001 From: pavlosb Date: Mon, 22 Apr 2024 14:47:34 +0300 Subject: [PATCH] improve-file-delete --- application/controllers/Inspection.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/application/controllers/Inspection.php b/application/controllers/Inspection.php index 32a81cb..1cb1ce9 100644 --- a/application/controllers/Inspection.php +++ b/application/controllers/Inspection.php @@ -972,13 +972,18 @@ public function dynimg($id) { public function removeimg() { $imgid = $this->input->post('id'); $filename = $this->itindata_model->getsingleimg($imgid); + if (file_exists('upload/'.$filename)) { $delete=unlink('upload/'.$filename); if($delete){ $this->itindata_model->delsingleimg($imgid); $status = "ok"; }else{ $status = "nok"; +} } else { + $this->itindata_model->delsingleimg($imgid); + $status = "ok"; } + $this->output->set_header("Cache-Control: no-cache, must-revalidate"); $this->output->set_header("Expires: Mon, 4 Apr 1994 04:44:44 GMT"); $this->output->set_header("Content-type: application/json");