how to submit form with enctype multipart/form-data in jquery
-
26-09-2019 - |
Question
i'm using form with enctype multipart/form-data for uploading photo, so below is my code for normal form submit,
$.ajax({
type: "POST",
url: loadUrl,
cache: false,
success: function(html){
$(outputLocation).html(html);
}
});
how this should alter, so its applicable for multipart/form-data type form in jquery
thanks in advance
Solution
Just check out the below plugin if it helps -
http://www.fyneworks.com/jquery/multiple-file-upload/#tab-Overview
OTHER TIPS
Here some interesting instructions by Ben Nadel.
You can't submit files over XMLHttpRequest (since you can't read the data from the user's HDD in JS).
jQuery doesn't have built in support to deal with file inputs, you'll need to find a plugin or an alternative.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow