Image Ngfileupload-如何显示被拒绝文件的图像名称?
我已经创建了此文件,但我收到了被拒绝的文件错误消息,但如何才能获得被拒绝的文件名?还是有更简单的方法来执行这项任务?我上传了多个文件,并对它们进行了检查,没有文件应该大于1MB。这是我的密码Image Ngfileupload-如何显示被拒绝文件的图像名称?,image,angular,upload,ng-file-upload,Image,Angular,Upload,Ng File Upload,我已经创建了此文件,但我收到了被拒绝的文件错误消息,但如何才能获得被拒绝的文件名?还是有更简单的方法来执行这项任务?我上传了多个文件,并对它们进行了检查,没有文件应该大于1MB。这是我的密码 <body ng-app="fileUpload" ng-controller="MyCtrl"> <h4>Upload on file select</h4> <button ngf-select="uploadFiles($files
<body ng-app="fileUpload" ng-controller="MyCtrl">
<h4>Upload on file select</h4>
<button ngf-select="uploadFiles($files)" multiple
accept="image/*" ngf-model-invalid="invalidImages" ngf-max-size="1MB">Select Files</button>
<br>
{{invalidImages[0].$error}}
<br>Files:
<ul>
<li ng-repeat="f in files" style="font:smaller">
{{f.name}}
</li>
</ul>
<span class="progress" ng-show="progress >= 0">
<div style="width:{{progress}}%" ng-bind="progress + '%'"></div>
</span>
{{errorMsg}}
</body>
//inject angular file upload directives and services.
var app = angular.module('fileUpload', ['ngFileUpload']);
app.controller('MyCtrl', ['$scope', 'Upload', '$timeout', function ($scope, Upload, $timeout) {
$scope.uploadFiles = function (files) {
$scope.files = files;
if (files && files.length) {
Upload.upload({
url: 'https://angular-file-upload-cors-srv.appspot.com/upload',
data: {
files: files
}
}).then(function (response) {
$timeout(function () {
$scope.result = response.data;
});
}, function (response) {
if (response.status > 0) {
$scope.errorMsg = response.status + ': ' + response.data;
}
}, function (evt) {
$scope.progress =
Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});
}
};
}]);
选择文件时上载
选择文件
{{无效图像[0]。$error}
档案:
-
{{f.name}
{{errorMsg}}
//注入角度文件上传指令和服务。
var app=angular.module('fileUpload',['ngFileUpload']);
app.controller('MyCtrl',['$scope','Upload','$timeout',函数($scope,Upload,$timeout){
$scope.uploadFiles=函数(文件){
$scope.files=文件;
if(files&&files.length){
上传({
网址:'https://angular-file-upload-cors-srv.appspot.com/upload',
数据:{
文件:文件
}
}).然后(功能(响应){
$timeout(函数(){
$scope.result=response.data;
});
},功能(回应){
如果(response.status>0){
$scope.errorMsg=response.status+':'+response.data;
}
},函数(evt){
$scope.progress=
最小值(100,parseInt(100.0*evt.loaded/evt.total));
});
}
};
}]);