diff --git a/SITEFILES/not-found.png b/SITEFILES/not-found.png new file mode 100644 index 0000000..0f6bdc1 Binary files /dev/null and b/SITEFILES/not-found.png differ diff --git a/app/Controllers/Media.php b/app/Controllers/Media.php index 96f3f5b..8f1d854 100644 --- a/app/Controllers/Media.php +++ b/app/Controllers/Media.php @@ -95,28 +95,22 @@ class Media extends BaseController $webFileUid = $uriSegments[$segLen - 2]; $fileDetailResult = $this->getWebFileDetails($webFileUid); + if (count($fileDetailResult) == 0) { + log_message('info', "WEB FILE DATA NOT FOUND:::UID-> $webFileUid"); + $this->notFound(); + exit(); + } $fileDetails = $fileDetailResult[0]; //var_dump($fileDetails); -//'id' => string '12' (length=2) -//'uid' => string '4bdc1594-a0d4-4eba-9dff-9e62f5c28d69' (length=36) -//'member_id' => string '20' (length=2) -//'member_uid' => string '2f1f9c8a-d50b-4fac-9de3-081bbc07cc64' (length=36) -//'file_group' => string 'WEBSITE' (length=7) -//'filename' => string 'coronary-artery-disease.png' (length=27) -//'save_filename' => string '1767224858-coronary-artery-disease.png' (length=38) -//'file_type' => string 'png' (length=3) -//'file_size' => string '0' (length=1) -//'status' => string '1' (length=1) -//'added' => string '2025-12-31 18:47:38.905934' (length=26) -//'updated' => string '2025-12-31 18:47:38.905943' (length=26) - - // exit; -///var/www/html/uploads/uploads/DEV/WEBSITE/W0000000020/1767055095-practice-in-ai_1.jpg - // $target_file = "/var/www/html/uploads/uploads/DEV/WEBSITE/W0000000020/1767055095-practice-in-ai_1.jpg"; $target_file = $_ENV['UPLOAD_FOLDER'] . "/" . $fileDetails['file_group'] . "/W" . str_pad($fileDetails['member_id'], 10, '0', STR_PAD_LEFT) . "/" . $fileDetails['save_filename']; - //$target_file = "/var/www/html/SITEFILES/TEST/" . $filename; - log_message('info', "TARGET:::FILE-> $target_file"); + // Check if the file exists + if (!file_exists($target_file)) { + log_message('info', "WEB FILE NOT FOUND:::UID-> $target_file"); + $this->notFound(); + exit(); + } + log_message('info', "TARGET:::FILE-> $target_file"); $file_extension = $fileDetails['file_type']; // strtolower(substr(strrchr($filename, "."), 1)); $ctype = "image/jpeg"; switch ($file_extension) { @@ -194,4 +188,13 @@ class Media extends BaseController return $image_set[$selImg]; } + private function notFound() + { + $ctype = "image/png"; + $target_file = "/var/www/html/SITEFILES/not-found.png";; + $selectedFile = $target_file; + header('Content-type: ' . $ctype); + readfile($selectedFile); + exit(); + } }