From 5dd8fe46f3cd5064d41acf444ccd428b14c3826a Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Mon, 4 May 2026 01:59:47 +0300 Subject: [PATCH] Update: 2026-05-04 01:59:47 --- app/bootstrap/init.php | 2 +- app/modules_app/invoices/upload.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/bootstrap/init.php b/app/bootstrap/init.php index 6221fe3..cc91c60 100644 --- a/app/bootstrap/init.php +++ b/app/bootstrap/init.php @@ -6,7 +6,7 @@ declare(strict_types=1); // 1. Basic Constants -define('ROOT_PATH', dirname(__DIR__, 2)); +define('ROOT_PATH', realpath(dirname(__DIR__, 2))); define('APP_PATH', ROOT_PATH . '/app'); define('STORAGE_PATH', ROOT_PATH . '/storage'); diff --git a/app/modules_app/invoices/upload.php b/app/modules_app/invoices/upload.php index d984b62..338236b 100644 --- a/app/modules_app/invoices/upload.php +++ b/app/modules_app/invoices/upload.php @@ -36,12 +36,17 @@ if (!$stmt->fetch()) { // 4. Handle File Upload $dateFolder = date('Y-m-d'); -$uploadDir = STORAGE_PATH . '/invoices/' . $tenantId . '/' . $companyId . '/' . $dateFolder . '/'; +$baseInvoicesDir = STORAGE_PATH . '/invoices'; +if (!is_dir($baseInvoicesDir)) { + mkdir($baseInvoicesDir, 0777, true); +} + +$uploadDir = $baseInvoicesDir . '/' . $tenantId . '/' . $companyId . '/' . $dateFolder . '/'; if (!is_dir($uploadDir)) { if (!mkdir($uploadDir, 0777, true)) { error_log("UPLOAD ERROR: Failed to create directory: " . $uploadDir); - json_error('فشل في إنشاء مجلد التخزين', 500); + json_error('فشل في إنشاء مجلد التخزين: ' . $uploadDir, 500); } }