🚀 مُصادَق: تحديث برمجي جديد 2026-05-03 02:38

This commit is contained in:
Hamza-Ayed
2026-05-03 02:38:54 +03:00
parent 2579998cc7
commit ce9f14c7a3
7 changed files with 384 additions and 42 deletions

View File

@@ -22,9 +22,9 @@ final class FileStorageService
$mime = finfo_file($finfo, $file['tmp_name']);
finfo_close($finfo);
$allowedMimes = ['application/pdf', 'image/jpeg', 'image/png', 'image/webp'];
$allowedMimes = ['application/pdf', 'image/jpeg', 'image/png', 'image/webp', 'application/json', 'text/plain', 'text/xml', 'application/xml'];
if (!in_array($mime, $allowedMimes)) {
throw new Exception("نوع الملف غير مسموح به");
throw new Exception("نوع الملف غير مسموح به ({$mime})");
}
// 2. Generate path
@@ -37,8 +37,15 @@ final class FileStorageService
$filename = hash('sha256', $file['name'] . time() . uniqid()) . '.' . $extension;
$targetPath = "{$dir}/{$filename}";
if (isset($file['error']) && $file['error'] !== UPLOAD_ERR_OK) {
throw new Exception("حدث خطأ أثناء رفع الملف من المتصفح. كود الخطأ: " . $file['error']);
}
if (!move_uploaded_file($file['tmp_name'], $targetPath)) {
throw new Exception("فشل رفع الملف");
// Fallback for some non-standard PHP environments
if (!copy($file['tmp_name'], $targetPath)) {
throw new Exception("فشل نقل الملف إلى المسار النهائي: " . $targetPath);
}
}
return $targetPath;