I have the following image upload code
if(isset($_POST['upload'])){
//INFO IMAGEM
$file = $_FILES['img'];
$numFile = count(array_filter($file['name']));
//PASTA
$folder = 'upload';
if($numFile <= 0)
echo 'Selecione uma Imagem!';
else{
for($i = 0; $i < $numFile; $i++){
$name = $file['name'][$i];
$type = $file['type'][$i];
$size = $file['size'][$i];
$tmp = $file['tmp_name'][$i];
$extensao = @end(explode('.', $name));
$novoNome = rand().".$extensao";
$identificador = $_POST['EdicaoId'];
$UrlImagem = $folder.'/'.$novoNome;
if(move_uploaded_file($tmp, $folder.'/'.$novoNome)){
$SalvaUrl = $conn->prepare("INSERT INTO revistas (id,url) VALUES (:id,:url)");
$SalvaUrl->bindParam(':id',$identificador);
$SalvaUrl->bindParam(':url',$UrlImagem);
$SalvaUrl->execute();
}}}}
Only the images in the upload directory are saved, but when sending to the database only the first one selected is registered.