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 @@