Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 26, 2021 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/acaa0fe2660fddfe90de5c9b15fae574 to your computer and use it in GitHub Desktop.
Save parzibyte/acaa0fe2660fddfe90de5c9b15fae574 to your computer and use it in GitHub Desktop.
<?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