【实例简介】asp.net webapi ajax上传文件示例(jquery)
【实例截图】
【核心代码】
Upload
@section scripts {
$(document).ready(function () {
$('#myFile').change(function () {
var file = this.files[0];
var formData = new FormData();
formData.append('MyFile', file);
$.ajax({
type: 'POST',
url: 'api/files',
data: formData,
contentType: false,
processData: false,
success: function () {
alert('File uploaded successfully!');
},
error: function () {
alert('OOOPS something went wrong!');
}
});
});
});
}