How can I upload files asynchronously with jQuery?
The “enctype” has to be mentioned in the AJAX call.
For example:
$(document).ready(function ( ) {
$(“#uploadbutton”).click(function ( ) {
var filename = $(“#file”).val(
);
$.ajax({
type: “POST”,
url: “addFile.do”,
enctype: ‘multipart/form-data’,
data: {
file: filename
},
success: function
( ) {
alert(“Data Uploaded: “);
}
});
});
});