title: how to get file info returned after sending it to another php file using ajax
body: <p>The code i have written is to send any uploaded file to a php page. I want the response to be an array containing all the information about that file. Also i have used "POST" method to upload a file.Is it ok? </p>
  
  <p>i want a neat and clean array which will contain information about the file ,like name,size,type etc. But i am getting an array like the following:</p>
  
  <p><a href="https://i.stack.imgur.com/5hkLv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5hkLv.png" alt="enter image description here"></a></p>
  
  <p>How i can manage that? full code:</p>
  
  <p>fileupload.php file :</p>
  
  <pre><code>&lt;?php  ?&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;input type='file' id='up' name='image'&gt;
  &lt;div id='imageholder' style='width:300px;height:300px;border:1px solid black;'&gt;&lt;/div&gt;
  &lt;span id='info' style='color:red;'&gt;&lt;/span&gt;
  &lt;script&gt;
  
  
  function fileread(event){
  
    if (window.FileReader &amp;&amp; window.Blob) {
  
  
    /* Handle local files */
  
          var file = event.target.files[0];
          var formdata=new FormData();
          formdata.append(document.getElementById('up').name,file,file.name);
  
  
                  var xhr=new  XMLHttpRequest();
                  xhr.onreadystatechange=function(e){
                      if(xhr.readyState==4 &amp;&amp; xhr.status==200){
                            console.log(xhr.response);
                      }
                  }
                  xhr.open('post',"../practice/classes/testimag.php",true);
                  xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                  xhr.send(formdata);
  
  
  
      }else {
       // File and Blob are not supported
              console.log('file and blob is not supported');
         } 
  
  
  
    } 
  
      document.getElementById('up').addEventListener('change',fileread,false);
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>testimag.php file :</p>
  
  <pre><code>&lt;?php  
      if(isset($_POST) &amp;&amp; !empty($_POST)){
  
          print_r($_POST);
      }
  ?&gt;
  </code></pre>