Post array does not storing file inputs

150 views Asked by At

I'm facing this strange issue.

I need to upload multiple image with one input. On the input I have a js code that shows me the uploaded image, but when I try to check the $_POST array the image are not submitted.

Half an hour ago it worked well, so I thought it was a cache problem, but even if I empty the cache I cant manage the problem. I cant remember if I changed something, but the code seems to be the same as before (when the code worked).

I work with MAMP on windows 10.

Here is the html (the "form-question" div including the image input is the last one below):

  <form action="?mode=dati" method="post" id="dati" enctype="multipart/form-data">
   <div class="form-question">
<label for="n2">Nome dell'azienda</label>
<input type="text" id="n2" name="nomeAzienda" value="<?php echo $_SESSION['nomeAzienda']?>">
 </div>
 <div class="form-question">
  <label for="n3">Indirizzo</label>
  <input type="text" id="n3" name="indirizzo" value="<?php echo $_SESSION['indirizzo']?>">
  </div>
  <div class="flex">
   <label for="n3">Cap</label>
   <input type="text" id="n3" name="cap" value="<?php echo $_SESSION['cap']?>">
   <label for="n4">Città</label>
   <input type="text" id="n4"name="citta" value="<?php echo $_SESSION['citta']?>">
   <label for="n5">Provincia</label>
   <input type="text" id="n5" name="provincia" value="<?php echo $_SESSION['provincia']?>">
   <label for="n6">P.IVA</label>
   <input type="text" id="n6" name="partitaIva" value="<?php echo $_SESSION['partitaIva']?>">
  </div>
  <div class="form-question">
  <label for="n7">Indirizzo email</label>
 <input type="text" name="email" id="n7" value="<?php echo $_SESSION['email']?>">
  </div>
 <div class="form-question"> 
    <label for="immagine">Immagine</label>
    <input type="file" name="immagine[]" class="form-control"  
    oninput="immagine_preview.src=window.URL.createObjectURL(this.files[0]); 
    immagine_preview1.src=window.URL.createObjectURL(this.files[1]); 
    immagine_preview2.src=window.URL.createObjectURL(this.files[2]); " multiple/>
    <img id="immagine_preview" width="100px" height="100px"> 
    <img id="immagine_preview1" width="100px" height="100px"> 
    <img id="immagine_preview2" width="100px" height="100px"> 
   </div>
  <div class="button-wrapper">
  <button type="submit" id="registra">Registra i dati</button>
  <button type="button" id="prosegui" class="disabled">Prosegui</button>
 </div>
 </form>

And here is the php:

if ( $_GET ) {
 if ( isset( $_GET[ 'id_sondaggio' ] ) || isset( $_GET[ 'mode' ] ) ) {
  $id_sondaggio = $_GET[ 'id_sondaggio' ];
  $mode = $_GET[ 'mode' ];
  }
 }
 if ( $mode == 'dati' ) {
 var_dump($_POST);
    die();
  }

I'm not getting what's wrong here. Thank you for all your help.

0

There are 0 answers