This commit is contained in:
Lizandro Guarnizo
2026-03-16 21:55:23 -05:00
parent 4106840a39
commit 0fddff6c5b
2 changed files with 26 additions and 2 deletions
+12 -1
View File
@@ -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;