Angular js图片上传如何检查宽度和高度示例我的withd = 200和heidht = 200如果给出超过像素它的显示是错误我怎么可以使用它如果我尝试一些东西可以解决它
HTML
<div class="form-group">
<label class="col-sm-2 control-label">Logo :</label>
<div class="col-sm-4">
<input filestyle="" type="file" name="file" required="" ng-model="form.logo" onchange="angular.element(this).scope().add(this.files).checkPhoto(this)" accept="image/jpeg,image/jpg" data-classbutton="btn btn-default" data-classinput="form-control inline" class="form-control" />
<br><label Style="color: Red;">Logo should be in (550 X 150) size</label>
</div>
</div>
JS
$scope.fileList1 = [];
$scope.add1 = function(file1) {
console.log(file1);
for (var i = 0; i < file1.length; i++) {
if (file1[i].type == 'image/jpeg' || file1[i].type == 'image/jpg' || file1[i].type == 'image/tif' || file1[i].type == 'image/tiff') {
var item = {
name: file1[i].name,
file: file1[i]
};
$scope.fileList1.push(item);
var f = file1[i],
r = new FileReader();
console.log($scope.fileList1);
r.onloadend = function(e) {
}
r.readAsDataURL(f);
} else {
$('#file1').val('');
Notify.alert('Upload only .jpeg,jpg,tiff,tif format file', {
status: 'warning',
pos: 'top-right',
timeout: 3000
});
}
}
};
答案 0 :(得分:0)
您可以使用ng-flow(一个库在AngularJS上传文件),并在其添加了流文件的/流文件的处理程序中检查图像维度。
以下是AidasK的一个例子:https://github.com/flowjs/ng-flow/issues/126