title: PHP : Multiple files upload working randomly
body: <p>I have a problem with my multiple file uploading script.</p>
  
  <p>Here's my code :</p>
  
  <p>Admin.php:</p>
  
  <pre><code>&lt;form method="post" action="upload.php" enctype="multipart/form-data"&gt;
       &lt;input multiple="multiple" type="file" name="file[]"&gt;
       &lt;input type="submit" name="send" value="Envoyer Images"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Upload.php:</p>
  
  <pre><code>&lt;?php
  session_start();
  
  $message = '';
  
  $extensions = array('.png', '.jpg', '.jpeg', '.JPG', '.PNG', '.JPEG');
  
  try{
      $db = new PDO('mysql:host=localhost;dbname=db', 'root', '');
  }
  catch(Exception $e){
      die('Erreur : ' . $e-&gt;getMessage());
  }
  
  $query = $db-&gt;prepare('SELECT max(id) as id FROM t_picture');
  $query-&gt;execute();
  $data = $query-&gt;fetch();
  
  $i = $data['id'] == NULL ? 0 : $data['id'];
  
  echo 'i = ' . $i;
  
  if(isset($_FILES['file'])){
      $dossier = 'pictures/';
  
      $message = '#1 Reached';
  
      foreach ($_FILES['file']['tmp_name'] as $index =&gt; $tmpName){
  
          $message = '#2 Reached';
  
          if(!empty($_FILES['file']['error'][$index])){
              $message = 'There is an error #2';
              break;
          }
  
          $ext = strrchr($_FILES['file']['name'][$index], '.');
  
          $tmp_name = strval($i) . $ext;
  
          echo 'Name : ' . $tmp_name;
  
  
          if(!empty($tmpName) &amp;&amp; is_uploaded_file($tmpName) &amp;&amp; in_array(strrchr($tmp_name, '.'), $extensions)){
              echo '#4 Reached';
              move_uploaded_file($tmpName, $dossier . $tmp_name);
              $i++;
              $message += '&lt;p&gt;Index '. strval($i) .' uploaded !&lt;/p&gt;';
          }
  
      }
  }
  else{
      $message ='Is not set';
  }
  
  echo $message;
  </code></pre>
  
  <p>The thing is, I can upload one or multiple files, it works according to the files i'm uploading.</p>
  
  <p>When the problem occured, i think that's because i'm bursting a 2M limit but i've changed the max_file_size value in my php.ini, and my phpinfo() correctly indicate 64000M (Test value).</p>
  
  <p>So when it desn't work, i have an Undifined Index for each call to $_FILES['file']..
  Do you know what's wrong?</p>