來源:https://blog.csdn.net/wooden_people/article/details/88762342
//彈窗關閉之后清空已選擇文件
$scope.excCancel = function () {
$("#file").val("");//獲取文件后清空值
}
/* 上傳函數(shù) */
// 判斷是不是exl 或 exls 文件
if(!($("#file")[0].files[0].type === "application/vnd.ms-excel" || $("#file")[0].files[0].type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")){
Alert("請選擇EXCEL格式的文件!")
return false;
}
var formdata = new FormData();
formdata.append("Filedata", $("#file")[0].files[0]);
//發(fā)送請求
$.ajax({
url:"",
type: "POST",
cache: false,
async: false,
data: formdata,
processData: false,
contentType: false,
headers: {
ContentType: "text/html;charset=utf-8"
},
success: function(data) {}
<input type="file" name="file" id="file" ng-src={{files[0].name}} onchange='angular.element(this).scope().fileChanged(this)'>