// 上传文件地点 var uploadUrl = apiInterceptor.webApiHostUrl + ‘/test/Upload‘; // angularjs上传要领 $scope.upload = function() {if ($scope.file) { // 选中文件 importData(); } }; // 导入数据 var importData = function() { if (!$scope.file || !$scope.file.name) { SweetAlert.info(‘请选择文件‘); return; } // $q需要注入 var deferred = $q.defer(); var tempFileName = PWC.newGuid() + ‘.dat‘; var token = $(‘input[name="__RequestVerificationToken"]‘).val(); Upload.upload({ url: uploadUrl, data: { cancel: false, filename: $scope.file.name, }, file: $scope.file, resumeChunkSize: resumable ? $scope.chunkSize : null, headers: { ‘Access-Control-Allow-Origin‘: ‘*‘, Authorization: apiInterceptor.tokenType + ‘ ‘ + apiInterceptor.apiToken, __RequestVerificationToken: token, withCredentials: true }, __RequestVerificationToken: token, withCredentials: true }).then(function(resp) { var ret = resp.data; deferred.resolve(); }, function(resp) { deferred.resolve(); console.log(‘Error status: ‘ + resp.statusText); }, function(evt) { deferred.resolve(); var progressPercentage = parseInt(100.0 * evt.loaded / evt.total); $log.debug(‘progress: ‘ + progressPercentage + ‘% ‘ + evt.config.data.file.name); }); };
,相关文章
- js中return false,return,return true的用法及差别
- return false 和 return true
- js中return、return false 、return true各自代表什么含义
- ceph rgw java sdk 使用域名访问服务时需要设置s3client的配置项 PathStyleAccess 为true, 负责将报域名异常
- -DskipTests和- dmaven.skip =true之间的区别是什么
- jquery中 cache: true和false的区别
- jquery中这句 .stop(false,true); 什么意思
- setInterval(),setTimeout(),location.reload(true)
- Activiti6.0 安装出错 log4j:ERROR setFile(null,true) call failed.
- How to secure the ASP.NET_SessionId cookie? 设置ASP.NET_SessionId Secure=true