Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74735

Sending a form with a jquery file by ajax

$
0
0

I've been stuck on this problem for days now. My goal is to create a form to send an image to the server through Ajax via jQuery.

I already asked the question here (Problem sending a form with a jquery file component by ajax), but it's been closed and it still doesn't work. From my question, I changed the sending function like this (according to this post: jQuery AJAX file upload PHP):

$( "#sendProfileImg").on('submit', function(e) {
  e.preventDefault();
  var file_data = $('#profileImgFile').prop('files')[0];   
  var form_data = new FormData();                  
  form_data.append('file', file_data);
  console.log(form_data); 
  $.ajax({
    url: 'uploadImage.php',
    data: form_data,
    type: 'POST',
          dataType: 'text',
          contentType: false,
          cache: false,
          processData:false,
    success: function( data ) {
      console.log(data);
    }
  });
});

But the answer I get from my uploadImage.php file (which consist of just var_dump($_POST);) is the following:

array(0) {
}

Any advice?


Viewing all articles
Browse latest Browse all 74735

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>