jQuery / AJAX - send additional data together with file upload

前端 未结 3 1857
旧时难觅i
旧时难觅i 2021-01-07 07:34

I am uploading files to the server using jQuery:

 $.ajax({
    url : \'http://www.example.com\',
    dataType : \'json\',
    cache : false,
    contentType          


        
3条回答
  •  生来不讨喜
    2021-01-07 08:19

    You have to serialize the form using the FormData object instead of only sending the file.

    var formData = new FormData($("form")[0]);
    

提交回复
热议问题