Hi, I was wondering if there is a way to preview the images before I upload them using angularjs? I am using this library. https://github.com/danialfarid/angular-file-upload
Thank. Here is my code:
template.html
<div ng-controller="picUploadCtr"> <form> <input type="text" ng-model="myModelObj"> <input type="file" ng-file-select="onFileSelect($files)" > <input type="file" ng-file-select="onFileSelect($files)" multiple> </form> </div>
controller.js
.controller('picUploadCtr', function($scope, $http,$location, userSettingsService) { $scope.onFileSelect = function($files) { //$files: an array of files selected, each file has name, size, and type. for (var i = 0; i < $files.length; i++) { var $file = $files[i]; $http.uploadFile({ url: 'server/upload/url', //upload.PHP , node.js route, or servlet uplaod url) data: {myObj: $scope.myModelObj}, file: $file }).then(function(data, status, headers, config) { // file is uploaded successfully console.log(data); }); } }
angularjs ajax upload file-upload angularjs-directive
user1424508 Sep 12 '13 at 3:41 on 2013-09-12 03:41
source share