1. Go to this page and download the library: Download iscosta77/upload-multiple library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
iscosta77 / upload-multiple example snippets
use Hermes\UploadMultiple\UploadMultiple;
use Iscos\Voodoo\Voodoo;
$db = Voodoo::fromEnv(); // .env formato Laravel
$multi = new UploadMultiple($db, [
'pasta' => 'uploads',
'max_tamanho' => 2 * 1024 * 1024,
'permitidos' => ['jpg', 'png', 'webp'],
'max_arquivos'=> 10,
]);
// $_FILES['fotos'] com name[], tmp_name[], ... (form: <input type="file" multiple name="fotos[]">)
$resultado = $multi->salvarVarios($_FILES['fotos'], 'galeria', $_POST, [
'webp' => 80,
'thumbs' => [[300, null], [300, 300]],
]);
echo $resultado['total']; // quantos foram enviados
foreach ($resultado['registros'] as $r) { } // cada upload (com id e imagem_id)
print_r($resultado['erros']); // ['arquivo.jpg' => 'motivo', ...]