How to use FormData for AJAX file upload?

后端 未结 9 1520
不思量自难忘°
不思量自难忘° 2020-11-21 06:13

This is my HTML which I\'m generating dynamically using drag and drop functionality.

9条回答
  •  深忆病人
    2020-11-21 07:01

    Better to use the native javascript to find the element by id like: document.getElementById("yourFormElementID").

    $.ajax( {
          url: "http://yourlocationtopost/",
          type: 'POST',
          data: new FormData(document.getElementById("yourFormElementID")),
          processData: false,
          contentType: false
        } ).done(function(d) {
               console.log('done');
        });
    

提交回复
热议问题