2017-08-05 95 views

回答

2

可以使用角文件上傳 先安裝:

bower install bower install angular-file-upload 

然後將其添加爲您的應用程序的依賴。

angular.module('your-app-name', ['angularFileUpload']); 

在你的控制器,注入FileUploader服務:

angular.module('your-app-name').controller('ctrlName', 
     ['$scope','FileUploader', function($scope, FileUploader) { 
     $scope.uploader = new FileUploader({ 
          url: 'server_url_here' 
        //you can add other configuration here like xsrf headers 
      }); 
     }]); 

然後在您的html:

   Multiple 
       <input type="file" nv-file-select="" uploader="uploader" multiple /><br/> 

       Single 
       <input type="file" nv-file-select="" uploader="uploader" /> 

你可以在這裏找到一個詳細的解釋: https://github.com/nervgh/angular-file-upload 一個例子: https://github.com/nervgh/angular-file-upload/tree/master/examples/simple

+1

感謝您的迴應,您可以幫我使用ASP.NET MVC控制器還請 – Navjyot

+0

嗨,對不起,對於最近的回覆...可能是我可以指導你一個很好的資源/專家,他已經很好地說明了整合角度與asp.net以及遵循的最佳實踐。查看此鏈接:www.bradoncode.com/blog/2012/11/the-code-review-aspnet-10-years-on-2.html –