title: How to fix PHP "Invalid Argument Supplied For Foreach()"
body: <pre><code>&lt;?php
  include "config.php";
  if(isset($_FILES['berkas'])){
      foreach ($_FILES['berkas']['name'] as $file=&gt;$name){
          $filename = date('Ymd-His',time()).mt-rand().'-'.$name;
          try{
              if(move_uploaded_file($_FILES['berkas']['tmp_name'][$file], 'uploads/'.$filename));{
                  $stmt= $db-&gt;prepare("insert into multipleload values('',?)");
                  $stmt -&gt;bindParam(1,$filename);
                  $stmt-&gt;execute();
  
              }
          } catch (Exception $e){
              echo $e;
          }
  
      }
  }   
  ?&gt;
  </code></pre>
  
  <p>Error is on line 3
  I've already tried if(is_array()){ } but it doesn't stop error message. </p>
  
  <p>I'm trying to make a document submission php file btw. I've looked through previous posts and have really only found that clearly its not getting an array. </p>