0
是否可以将文件对象转换为图像对象?
我需要从文件(该文件是一个图像)的宽度和高度,这是我的代码:AngularJS - 将文件对象转换为图像对象
视图:
<button id="image_file" class="md-button md-raised md-primary"
type="file" ngf-select="uploadFile($file)">
SELECT FILE
</button>
<md-input-container>
<div class="raised">
<input id="image_file_name" type="text" ng-model="vm.file.name"></input>
</div>
</md-input-container>
控制器:
app.controller('imageController', function($scope, fileService) {
$scope.vm = {};
$('.intro').show(1000);
$scope.uploadFile = function(file) {
$scope.vm.file = "";
$scope.vm.file = file; //<---- for example here, how it should be done?
fileService.uploadFile($scope);
}
服务:
angular.module('app')
.service('fileService', function ($http, validationService) {
this.uploadFile = function ($scope){
if (validationService.isFileValidate($scope)) {
$scope.vm.acceptableFormat = true;
} else {
$scope.vm.acceptableFormat = false;
}
};
});
如何选择文件?我的意思是''在哪里? – Searching
@查看它在'view'代码顶部的按钮下,我在这里使用ng-file-upload – dante
仍然不行吗? – Searching