Update: 2026-06-25 03:51:57

This commit is contained in:
Hamza-Ayed
2026-06-25 03:55:10 +03:00
parent 6db2ece2ce
commit 4f4958defb

View File

@@ -17,10 +17,6 @@ $driverID = filterRequest('driverID');
$imageType = filterRequest('imageType');
$country = filterRequest('country');
if (empty($driverID)) {
jsonError('driverID is required.');
}
if (empty($imageType)) {
jsonError('imageType is required.');
}
@@ -28,6 +24,7 @@ if (empty($imageType)) {
// --------- تحديد الدولة ---------
$country = strtolower(trim($country ?: ''));
if (empty($country)) {
if (!empty($driverID)) {
try {
$stmt = $con->prepare("SELECT country FROM drivers WHERE id = ?");
$stmt->execute([$driverID]);
@@ -36,15 +33,22 @@ if (empty($country)) {
$country = '';
}
}
if (empty($country)) {
$country = 'jordan';
}
}
if (!in_array($country, ['syria', 'jordan', 'egypt'])) {
$country = 'syria';
$country = 'jordan';
}
uploadLog("📥 Params: driverID=$driverID, imageType=$imageType, country=$country");
// --------- بادئة اسم الملف ---------
$prefix = !empty($driverID) ? $driverID : 'unregistered';
uploadLog("📥 Params: driverID=" . ($driverID ?: 'null') . ", imageType=$imageType, country=$country");
// --------- رفع الملف ---------
$targetDir = __DIR__ . "/../../auth/uploads/{$country}/";
$result = uploadImageSecure('image', $targetDir, $driverID . '_' . $imageType);
$result = uploadImageSecure('image', $targetDir, $prefix . '_' . $imageType);
if (!$result['success']) {
uploadLog("❌ Upload failed: {$result['error']}", 'ERROR', [
@@ -63,7 +67,7 @@ $basePath = rtrim(dirname(dirname(dirname($_SERVER['SCRIPT_NAME']))), '/');
$url = "$protocol://$host{$basePath}/auth/uploads/{$country}/{$result['filename']}";
uploadLog("✅ Uploaded: {$result['path']} -> $url", 'INFO', [
'driverID' => $driverID,
'driverID' => ($driverID ?: 'null'),
'imageType' => $imageType,
'country' => $country,
]);
@@ -72,7 +76,7 @@ jsonSuccess([
'url' => $url,
'file_link' => $url,
'filename' => $result['filename'],
'driverID' => $driverID,
'driverID' => ($driverID ?: ''),
'imageType' => $imageType,
'country' => $country,
]);