From a0b724e30db5756847d7617a05a582e0bfc8e8fd Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 17 Apr 2026 04:20:49 +0530 Subject: [PATCH] Fix serve_legacy_upload to also check public/uploads/ (FCPATH) --- app/Controllers/Opd.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Controllers/Opd.php b/app/Controllers/Opd.php index e823c9c..5252049 100644 --- a/app/Controllers/Opd.php +++ b/app/Controllers/Opd.php @@ -6589,13 +6589,18 @@ class Opd extends BaseController return $this->response->setStatusCode(404)->setBody('Not Found'); } - // Try project-root uploads/ (CI3 legacy location). + // 1. public/uploads/ — CI4 standard location (covers servers that route all + // requests through index.php, e.g. Nginx without try_files static bypass). + $publicUploadsPath = rtrim(FCPATH, '/\\') . '/uploads/' . $subpath; + // 2. Project-root uploads/ — CI3 legacy location. $legacyPath = rtrim(ROOTPATH, '/\\') . '/uploads/' . $subpath; - // Also try writable/uploads/ just in case. + // 3. writable/uploads/ — fallback. $writablePath = rtrim(WRITEPATH, '/\\') . '/uploads/' . $subpath; $filePath = ''; - if (is_file($legacyPath)) { + if (is_file($publicUploadsPath)) { + $filePath = $publicUploadsPath; + } elseif (is_file($legacyPath)) { $filePath = $legacyPath; } elseif (is_file($writablePath)) { $filePath = $writablePath;