title: PHP multiple file upload works, replacing files that already exist doesn't, any hints as to where i'm going wrong?
body: <p>My theory is that this should allow me to upload image files as replacements for existing images, using the same filename, but the upload fails under that context, whereas singular or multiple file uploads do work if the file doesn't already exist. </p>
  
  <p>My rudimentary understanding is that in theory, <code>move_uploaded_file</code> should be able to compensate, but in this case isn't.</p>
  
  <pre><code>if(isset($_POST['img-manage-update'])) :
  
      // Count total files
      $countfiles  = count($_FILES['files']['name']);
      $uploadquery = "UPDATE imagemanager SET (imc_descname, imc_filename) VALUES (?, ?) WHERE id = :id";     
      $uploader    = $dbc-&gt;prepare($uploadquery);
  
      // Loop all the files
      for($i = 0; $i&lt;$countfiles; $i++) :
  
          // File Name
          $filename = $_FILES['files']['name'][$i];
  
          // Get extension
          $extension = end((explode(".", $filename)));
  
          // Valid image extension            
          $validextension = array("png", "jpeg", "jpg");
  
          if(in_array($extension, $validextension)) :
              // Upload File
              if(move_uploaded_file($_FILES['files']['tmp_name'][$i], 'photos/'. $filename)) :
                  $uploader-&gt;execute(array($filename, 'photos/'. $filename));
              endif;
          endif;
  
      endfor;
      echo "File upload successful.";
  
  endif;
  </code></pre>