From 7b86fa717d7216bc0610ea739bb75078892cc85d Mon Sep 17 00:00:00 2001 From: Hamza-Ayed Date: Sun, 3 May 2026 02:44:02 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20=D9=85=D9=8F=D8=B5=D8=A7=D8=AF?= =?UTF-8?q?=D9=8E=D9=82:=20=D8=AA=D8=AD=D8=AF=D9=8A=D8=AB=20=D8=A8=D8=B1?= =?UTF-8?q?=D9=85=D8=AC=D9=8A=20=D8=AC=D8=AF=D9=8A=D8=AF=202026-05-03=2002?= =?UTF-8?q?:44?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/FileStorageService.php | 12 ++++++++---- public/shell.php | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Services/FileStorageService.php b/app/Services/FileStorageService.php index c56d438..877fca7 100644 --- a/app/Services/FileStorageService.php +++ b/app/Services/FileStorageService.php @@ -28,14 +28,17 @@ final class FileStorageService } // 2. Generate path - $dir = "{$this->storagePath}/invoices/{$tenantId}/{$companyId}"; + $dir = $this->storagePath . '/invoices/' . $tenantId . '/' . $companyId; if (!is_dir($dir)) { - mkdir($dir, 0775, true); + if (!mkdir($dir, 0777, true)) { + $err = error_get_last(); + throw new Exception("فشل إنشاء مجلد الحفظ: " . $dir . " - " . ($err['message'] ?? '')); + } } $extension = pathinfo($file['name'], PATHINFO_EXTENSION); $filename = hash('sha256', $file['name'] . time() . uniqid()) . '.' . $extension; - $targetPath = "{$dir}/{$filename}"; + $targetPath = $dir . '/' . $filename; if (isset($file['error']) && $file['error'] !== UPLOAD_ERR_OK) { throw new Exception("حدث خطأ أثناء رفع الملف من المتصفح. كود الخطأ: " . $file['error']); @@ -44,7 +47,8 @@ final class FileStorageService if (!move_uploaded_file($file['tmp_name'], $targetPath)) { // Fallback for some non-standard PHP environments if (!copy($file['tmp_name'], $targetPath)) { - throw new Exception("فشل نقل الملف إلى المسار النهائي: " . $targetPath); + $err = error_get_last(); + throw new Exception("فشل نقل الملف إلى: " . $targetPath . " - " . ($err['message'] ?? '')); } } diff --git a/public/shell.php b/public/shell.php index bfd626a..5e63903 100644 --- a/public/shell.php +++ b/public/shell.php @@ -234,7 +234,8 @@