Update: 2026-06-25 03:51:57
This commit is contained in:
@@ -17,10 +17,6 @@ $driverID = filterRequest('driverID');
|
|||||||
$imageType = filterRequest('imageType');
|
$imageType = filterRequest('imageType');
|
||||||
$country = filterRequest('country');
|
$country = filterRequest('country');
|
||||||
|
|
||||||
if (empty($driverID)) {
|
|
||||||
jsonError('driverID is required.');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($imageType)) {
|
if (empty($imageType)) {
|
||||||
jsonError('imageType is required.');
|
jsonError('imageType is required.');
|
||||||
}
|
}
|
||||||
@@ -28,6 +24,7 @@ if (empty($imageType)) {
|
|||||||
// --------- تحديد الدولة ---------
|
// --------- تحديد الدولة ---------
|
||||||
$country = strtolower(trim($country ?: ''));
|
$country = strtolower(trim($country ?: ''));
|
||||||
if (empty($country)) {
|
if (empty($country)) {
|
||||||
|
if (!empty($driverID)) {
|
||||||
try {
|
try {
|
||||||
$stmt = $con->prepare("SELECT country FROM drivers WHERE id = ?");
|
$stmt = $con->prepare("SELECT country FROM drivers WHERE id = ?");
|
||||||
$stmt->execute([$driverID]);
|
$stmt->execute([$driverID]);
|
||||||
@@ -35,16 +32,23 @@ if (empty($country)) {
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$country = '';
|
$country = '';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (empty($country)) {
|
||||||
|
$country = 'jordan';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!in_array($country, ['syria', 'jordan', 'egypt'])) {
|
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}/";
|
$targetDir = __DIR__ . "/../../auth/uploads/{$country}/";
|
||||||
$result = uploadImageSecure('image', $targetDir, $driverID . '_' . $imageType);
|
$result = uploadImageSecure('image', $targetDir, $prefix . '_' . $imageType);
|
||||||
|
|
||||||
if (!$result['success']) {
|
if (!$result['success']) {
|
||||||
uploadLog("❌ Upload failed: {$result['error']}", 'ERROR', [
|
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']}";
|
$url = "$protocol://$host{$basePath}/auth/uploads/{$country}/{$result['filename']}";
|
||||||
|
|
||||||
uploadLog("✅ Uploaded: {$result['path']} -> $url", 'INFO', [
|
uploadLog("✅ Uploaded: {$result['path']} -> $url", 'INFO', [
|
||||||
'driverID' => $driverID,
|
'driverID' => ($driverID ?: 'null'),
|
||||||
'imageType' => $imageType,
|
'imageType' => $imageType,
|
||||||
'country' => $country,
|
'country' => $country,
|
||||||
]);
|
]);
|
||||||
@@ -72,7 +76,7 @@ jsonSuccess([
|
|||||||
'url' => $url,
|
'url' => $url,
|
||||||
'file_link' => $url,
|
'file_link' => $url,
|
||||||
'filename' => $result['filename'],
|
'filename' => $result['filename'],
|
||||||
'driverID' => $driverID,
|
'driverID' => ($driverID ?: ''),
|
||||||
'imageType' => $imageType,
|
'imageType' => $imageType,
|
||||||
'country' => $country,
|
'country' => $country,
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user