title: sending JSON object along with file using FormData in ajax call and accessing the json object in PHP
body: <p>I am trying to send json object along with a file in ajax call as follows</p>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>$('#btn').on('click', function(){
      var file_data = $('#imgFile').prop('files')[0];
      var form_data = new FormData();
      let jsonObj = {
          'label1':'value1'
      };
      form_data.append('file', file_data);
      form_data.append('json', jsonObj);//json object which I am trying to send
      $.ajax({
          url: 'uploader.php',
          cache: false,
          contentType: false,
          processData: false,
          data: form_data,
          type: 'post',
          success: function(php_script_response){
              console.log(php_script_response);
          }
      });
  });
  </code></pre>
  
  <p>and in PHP I am able to retrieve the file sent in ajax call successfully but <strong>I dont know how to access the json object sent along with that file</strong></p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
  if ( 0 &lt; $_FILES['file']['error'] ) {
      echo 'Error: ' . $_FILES['file']['error'] . '&lt;br&gt;';
  }
  else {
      $file_ext=strtolower(end(explode('.',$_FILES['file']['name'])));
      move_uploaded_file($_FILES['file']['tmp_name'], 'uploadedFiles/1.' . $file_ext);
      echo $_POST['json'];
  }
  </code></pre>
  
  <p><strong>please let me know how to retrive the json object in php</strong></p>