🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 02:44
This commit is contained in:
@@ -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'] ?? ''));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user