From 94ebbb5793e014abd05b0e541fce7013bec4198f Mon Sep 17 00:00:00 2001 From: heama Date: Sat, 20 Jan 2024 13:51:27 +0530 Subject: [PATCH] file upload issue in book --- app/Controllers/Books.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Controllers/Books.php b/app/Controllers/Books.php index 473bf145..ebd43a51 100755 --- a/app/Controllers/Books.php +++ b/app/Controllers/Books.php @@ -145,9 +145,16 @@ class Books extends BaseController ##Step 5 : Check Existing and New Image Name Same Or not same no use to move on target folder if($new_img_name !== $existing_img_name){ $existing_images_record = $BooksModel->db->table('book_images') - ->where(['book_id'=>$book_id,'isactive'=>1,'type'=>1]) - ->get()->getRow(); + ->where(['book_id'=>$book_id,'isactive'=>1,'type'=>1]) + ->get()->getRow(); + + if ($existing_images_record) { $existing_image_id = $existing_images_record->book_img_id; + } else { + // Handle the case when the record does not exist + $existing_image_id = null; // Or set it to an appropriate default value + } + $this->logger->info("Books: Image Name are Differ".$new_img_name." & ".$existing_img_name); ## Step 6 : Different Image Name means removed on target folder using Unlink; if ($existing_image_id && $existing_img_name && is_file($img_path.$existing_img_name)) {