Update: 2026-05-04 01:59:47

This commit is contained in:
Hamza-Ayed
2026-05-04 01:59:47 +03:00
parent 3976a5346b
commit 5dd8fe46f3
2 changed files with 8 additions and 3 deletions

View File

@@ -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');

View File

@@ -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);
}
}