up
This commit is contained in:
@@ -56,7 +56,18 @@ if (!in_array($mime, $allowedMimes, true)) {
|
||||
// Generar nombre único y seguro
|
||||
$origExt = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
|
||||
$origExt = preg_replace('/[^a-z0-9]/', '', $origExt);
|
||||
if (!$origExt) $origExt = 'bin';
|
||||
if (!$origExt) {
|
||||
$mimeToExt = [
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/png' => 'png',
|
||||
'image/gif' => 'gif',
|
||||
'image/webp' => 'webp',
|
||||
'application/pdf' => 'pdf',
|
||||
'application/msword' => 'doc',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'docx',
|
||||
];
|
||||
$origExt = $mimeToExt[$mime] ?? 'bin';
|
||||
}
|
||||
|
||||
$newName = 'orden_' . date('Ymd_His') . '_' . bin2hex(random_bytes(4)) . '.' . $origExt;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user