remove random suffix from uploaded filenames: now {driverID}_{imageType}.{ext}
This commit is contained in:
@@ -59,6 +59,20 @@ if (!$result['success']) {
|
|||||||
jsonError($result['error']);
|
jsonError($result['error']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------- إزالة العشوائية من اسم الملف ---------
|
||||||
|
// الاسم يكون فقط: {driverID}_{imageType}.jpg (بدون random hex)
|
||||||
|
$ext = pathinfo($result['filename'], PATHINFO_EXTENSION);
|
||||||
|
$simpleName = $prefix . '_' . $imageType . '.' . $ext;
|
||||||
|
$simplePath = rtrim($targetDir, '/') . '/' . $simpleName;
|
||||||
|
|
||||||
|
if (file_exists($simplePath)) {
|
||||||
|
unlink($simplePath); // overwrite
|
||||||
|
}
|
||||||
|
rename($result['path'], $simplePath);
|
||||||
|
|
||||||
|
$result['filename'] = $simpleName;
|
||||||
|
$result['path'] = $simplePath;
|
||||||
|
|
||||||
// --------- بناء الرابط العام ---------
|
// --------- بناء الرابط العام ---------
|
||||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
||||||
$host = getenv('APP_DOMAIN') ?: ($_SERVER['HTTP_HOST'] ?? 'api.siromove.com');
|
$host = getenv('APP_DOMAIN') ?: ($_SERVER['HTTP_HOST'] ?? 'api.siromove.com');
|
||||||
|
|||||||
Reference in New Issue
Block a user