Sunday, 27 November 2016

javascript - How can I upload files asynchronously?

I would like to upload a file asynchronously with jQuery.






$(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: ");
}
});
});
});



File






Instead of the file being uploaded, I am only getting the filename. What can I do to fix this problem?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...