title: move_uploaded_file(): failed to open stream: Invalid argument in
body: <p>Uploaing multiple image via Ajax. I am using fd,.append() to send image but when i am reciving on another page then it's throwing error : move_uploaded_file(upload_documents/2017-10-04-04:41:39-aa - Copy - Copy.html): failed to open stream: Invalid argument in </p>
  
  <p><a href="https://i.stack.imgur.com/PIZzx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PIZzx.png" alt="enter image description here"></a></p>
  
  <p>so how can i slove this error please help..</p>
  
  <p>HTML Code :-</p>
  
  <pre><code> &lt;input type="file" class="form-control" name="txtBusinessImageName[]" multiple id="txtDocuName" &gt;
  
       &lt;label&gt;Select Parent&lt;/label&gt;
            &lt;select class="form-control" id="txtParentDocFolder"&gt;
              &lt;option value="0"&gt;--none--&lt;/option&gt;
      &lt;/select&gt;
  
    &lt;button type="button" class="btn btn-success pull-right btnUploadDocClick" &gt;Upload&lt;/button&gt;
  </code></pre>
  
  <p>Ajax Code :- </p>
  
  <pre><code>&lt;script&gt;
  
  $(".btnUploadDocClick").on("click",function(e){
  
      var total_img=$("#txtDocuName").get(0).files.length;
      if(total_img==0){
          alert("Pleas select an image");
      }
      else{
          alert(total_img);       
           for(var i=0; i&lt;=total_img-1; i++){
               var f_name=$("#txtDocuName").get(0).files.item(i).name;
               var f_size=$("#txtDocuName").get(0).files.item(i).size;
              console.log(f_name);
              console.log(f_size);
           }       
              var fd = new FormData();
              var file_data = $("#txtDocuName")[0].files;
  
              var selfolder=$("#txtParentDocFolder option:selected").val();
  
              fd.append("file0", file_data.length+1);
  
              for(var i = 0;i&lt;file_data.length;i++){
                  fd.append("file"+(i+1), file_data[i]);                          
              }
              fd.append("parent_name", selfolder);
              $.ajax({
                  url: 'upload_files_page.php',
                  data: fd,
                  contentType: false,
                  processData: false,
                  type: 'POST', async : true,
                  success: function(data){
                      //alert("Sucessfully Saved");
                      //fetch_product_image();
                  }
              }); 
        }; 
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>PHP Code :- </p>
  
  <pre><code>&lt;?php
      session_start();
      if(isset($_SESSION['login'])){
          include("root/db_connection.php");
          $userID=str_replace("'","",$_SESSION['login']);
          $parent_name=str_replace("'","",$_REQUEST['parent_name']);
  
          $total=$_REQUEST['file0'];
           for($i=1; $i&lt;$total; $i++)
           {
               $ctrl_id="file".$i;
               $file_name=$_FILES[$ctrl_id]['name'];
  
               $tmp_file_name= $file_name;
  
               $file_ext=pathinfo($tmp_file_name,PATHINFO_EXTENSION);
  
               $a1_file=str_replace(".".$file_ext,"",$tmp_file_name);
  
  
               $currentDate=date("Y-m-d-h:i:s");
               $orignal_file_name=$currentDate."-".$a1_file;
               $orignal_file_name=$orignal_file_name.".".$file_ext;
  
  
               $insQ=$db-&gt;query("insert into user_document(file_name,file_tmp_name,folder_id,created_by,created_on) values('$orignal_file_name','$file_name',$parent_name,$userID,now())") or die("");
  
               if($insQ==TRUE){
                   move_uploaded_file($_FILES[$ctrl_id]['tmp_name'],"upload_documents/".$orignal_file_name);
  
                   echo "Sucessfully Inserted !...";
               }
               else{
                   echo "0";
               }
           }  
      }
      else{
          echo "0";
      }
  ?&gt;
  </code></pre>