title: Troubleshooting file upload error code 4
body: <p>I am trying to upload multiple files to my server. If I try to upload a single file, it works fine. but if I try more than one, it gives me an error code 4, even though it does print the name of all the files correctly. Nothing is uploaded. I have the input type set correctly. Can someone help me? </p>
  
  <pre><code>Choose Image:&amp;nbsp;&amp;nbsp;&lt;input name="uploadedfile[]" type="file" multiple="true"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
              &lt;input type="submit" value="Upload Image!" style="margin-left:100px;"/&gt;
  </code></pre>
  
  <p>Below is the code:  </p>
  
  <pre><code>$i=0;
  foreach($_FILES['uploadedfile']['name'] as $f)
  {
      $file['name'] = $_FILES['uploadedfile']['name'][$i];
      $file['type'] = $_FILES['uploadedfile']['type'][$i];
      $file['tmp_name'] = $_FILES['uploadedfile']['tmp_name'][$i];
      $file['error'] = $_FILES['uploadedfile']['error'][$i];
      $file['size'] = $_FILES['uploadedfile']['size'][$i];
      if ($file["error"] &gt; 0)
      {
          echo "Error Code: " . $file["error"];
      }
  
      $target_path = "uploads/".basename($file["name"]); 
  
      if(move_uploaded_file($file["tmp_name"], $target_path)) 
      {
          echo basename($file['name'])."&lt;br /&gt;";
          echo basename($file['tmp_name'])."&lt;br /&gt;";
          echo $target_path;
  
      } else{
          echo "There was an error uploading the file, please try again!";
      }
      $i++;
  }
  </code></pre>
  
  <p>and my HTML form</p>
  
  <pre><code>&lt;div id="album_slider"&gt;
      &lt;div style="text-align:center;margin:20px auto;font-size:27px;"&gt;Upload Image&lt;/div&gt;
      &lt;br style="clear:both;font-size:0;line-height:0;height:0;"/&gt;
      &lt;div style="width:700px;margin:auto;height:250px;text-align:left;"&gt;
          &lt;form enctype="multipart/form-data" action="uploader.php" method="POST" name="form"&gt;
              Image Name:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="text" name="image_name" id="image_name"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
              &lt;input type="hidden" name="a_id" id="a_id" value="&lt;?php echo $a_id; ?&gt;"/&gt;
              Choose Image:&amp;nbsp;&amp;nbsp;&lt;input name="uploadedfile[]" type="file" multiple="true"/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
              &lt;input type="submit" value="Upload Image!" style="margin-left:100px;"/&gt;
          &lt;/form&gt;
      &lt;/div&gt;
      &lt;br style="clear:both;font-size:0;line-height:0;height:1px;"/&gt;
  &lt;/div&gt;
  </code></pre>