-
-
Save parzibyte/acaa0fe2660fddfe90de5c9b15fae574 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
https://parzibyte.me/blog | |
*/ | |
$conteo = count($_FILES["archivos"]["name"]); | |
for ($i = 0; $i < $conteo; $i++) { | |
$ubicacionTemporal = $_FILES["archivos"]["tmp_name"][$i]; | |
$nombreArchivo = $_FILES["archivos"]["name"][$i]; | |
$extension = pathinfo($nombreArchivo, PATHINFO_EXTENSION); | |
// Renombrar archivo | |
$nuevoNombre = sprintf("%s_%d.%s", uniqid(), $i, $extension); | |
// Mover del temporal al directorio actual | |
move_uploaded_file($ubicacionTemporal, $nuevoNombre); | |
} | |
// Responder al cliente | |
echo json_encode(true); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment