原生ajax上传文件
<input type="file" id="file_upload" onchange=" tjfile()">
function tjfile() {
var files = document.getElementById("file_upload").files;
var formdata_file = new FormData();
formdata_file.append("file", files[0]);
debugger;
$.ajax({
url: '${ctx}/fileUploads/fileUploads/save?biz_key='+$('#id').val(),
type: 'POST',
data: formdata_file,
contentType: false,
processData: false,
dataType: 'json',
success: function (res) {
alert('数据导入成功!');
},
error: function (e) {
alert('数据导入失败!');
}
});
return false;
}