I am new to ASP.NET MVC and AngularJS, How can I Upload file (Image/PDF/Doc) to server Folder By AngularJS Controller with ASP.NET MVC Controller
1 Answer
you can use the angular-file-upload first install it:
bower install bower install angular-file-upload
then add it as dependency in your app.
angular.module('your-app-name', ['angularFileUpload']);
In your controller, inject the FileUploader service:
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
});
}]);
Then in your html:
Multiple
<input type="file" nv-file-select="" uploader="uploader" multiple /><br/>
Single
<input type="file" nv-file-select="" uploader="uploader" />
You can find a detailed explanation here: https://github.com/nervgh/angular-file-upload An example: https://github.com/nervgh/angular-file-upload/tree/master/examples/simple
2 Comments
Navjyot
Thanks for response, Can you help me with ASP.NET MVC Controller also please
Leo Much
Hi, sorry for the late reply...may be i can guide you to a good resource/expert, he has explained very well on integrating angular with asp.net as well as best practices to follow. Check this link: www.bradoncode.com/blog/2012/11/the-code-review-aspnet-10-years-on-2.html