Update: 2026-06-16 01:17:28
This commit is contained in:
@@ -108,8 +108,13 @@ if (!is_dir($destDir)) { @mkdir($destDir, 0700, true); }
|
||||
$serverName = "{$driverIdSafe}__{$docType}{$ext}";
|
||||
$destPath = $destDir . '/' . $serverName;
|
||||
|
||||
// استبدال أي نسخة قديمة عن قصد (overwrite)
|
||||
if (is_file($destPath)) { @unlink($destPath); }
|
||||
// استبدال أي نسخة قديمة عن قصد (overwrite) - مع حماية ضد path traversal
|
||||
$resolvedDest = realpath($destPath) ?: $destPath;
|
||||
$resolvedRoot = realpath(UPLOAD_ROOT) ?: UPLOAD_ROOT;
|
||||
|
||||
if (is_file($destPath) && str_starts_with($resolvedDest, $resolvedRoot)) {
|
||||
@unlink($destPath);
|
||||
}
|
||||
|
||||
// نقل الملف
|
||||
if (!move_uploaded_file($tmpPath, $destPath)) {
|
||||
|
||||
Reference in New Issue
Block a user