I've try everything, can someone help me? Im getting 3 error on: foreach()...
PHP: 8.0 MYSQL: 5.1
foreach($_FILES["userfile"]["tmp_name"] as $key=>$tmp_name) {
$file_name=$_FILES["userfile"]["name"][$key];
$pasta_dir = "../www/layout/diario_de_obra/upload_img/";
$diretorio_img = $pasta_dir . $file_name;
$arquivo = $_FILES["userfile"]['tmp_name'][$key];
move_uploaded_file($arquivo, $diretorio_img);
print($file_name." enviado com sucesso!");
}
<div enctype="multipart/form-data"> <!-- action="upload" method="post" accept=”image/* -->
<label>Selecione as fotos de hoje aqui:
<input id="image-file" type="file" name="userfile[]">
<input id="image-file" type="file" name="userfile[]">
</label>
</div>
CodePudding user response:
After playing around with your example I came up with this
<form action="imageUpload.php" method="post" enctype="multipart/form-data">
<div> <!-- action="upload" method="post" accept=”image/* -->
<label>Selecione as fotos de hoje aqui:
<input id="image-file" type="file" name="userfile[]">
<input id="image-file" type="file" name="userfile[]">
</label>
</div>
<button type="submit">click me</button>
</form>
Now your PHP started working.