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