This article demonstrates learning MVC using angular file upload using bootstrap file style in Visual Studio 2017.

Angular File Upload

Angular file upload supports native Html5 uploads. It works with any server side platform which supports standard html form uploads. When file is added to the queue, it creates file item and uploader options are into this object. After, the items in the queue are ready for uploading.


  • Drag-n-drop upload
  • Upload progress
  • Validation file filter
  • File upload queue

Follow the steps you can use angular file upload in angular JS in MVC

  • Create MVC Project
  • Configure Angular file upload & Bootstrap filestyle
  • Work in Angular file upload

Create MVC Project

Open the visual studio 2017


Go to New menu >Click New & project. Now it will open New Project Window


You can select ASP.NET Web Application on Framework 4.5. Enter the name of project in “Solution name” textbox then click ok button.


One more window should be appearing. Select MVC Template in this popup & Click ok button. Now start cropping image.

Configure Angular File Upload & Bootstrap Filestyle

Right click above the project and go to the NuGet package manager then search ‘angularfileupload’.in browse tab & install it.


OR You can download the plug in from

Open the _Layout.cshtml and must refer the .js file from downloaded folder to this view page

  1. Plugin/angular/angular.min.js”
  2.  Plugin/angular-ui-router/release/angular-ui-router.min.js
  3.  Plugin/angular-file-upload/dist/angular-file-upload.min.js
  4. Plugin/bootstrap-filestyle/src/bootstrap-filestyle.js

Link your angular configurable file, whatever you give as the name

  1. App/App.module.js
  2. App/App.config.js
  3. App/IUController.js

Angular Module

You will need to include the module as a dependency on your application.

  1. var uiroute = angular
  2.     .module(‘uiroute’, [‘ui.router’,‘angularFileUpload’]);

Work in Angular image Upload

Using bootstrap file style directive make it as a single uploading attribute. Based on attribute you can set

  1. <input filestyle=“” type=“file” data-icon-name=“icon-upload” data-button-text=“Single” data-class-button=“btn btn-default” data-classinput=“form-control inline” nv-file-select=“” uploader=“uploader” class=“form-control” />

Html Code

Base drop zone

<!– Example: nv-file-drop=”” uploader=”{Object}” options=”{Object}” filters=”{String}”–>

Another drop zone with its own settings

<!– Example: nv-file-select=”” uploader=”{Object}” options=”{Object}” filters=”{String}”–>
<hr />
<input filestyle=”” type=”file” data-icon-name=”icon-upload” data-button-text=”Multiple” data-class-button=”btn btn-default” data-class-input=”form-control inline” nv-file-select=”” uploader=”uploader” multiple=”” class=”form-control” />
<br />
<input filestyle=”” type=”file” data-icon-name=”icon-upload” data-button-text=”Single” data-class-button=”btn btn-default” data-classinput=”form-control inline” nv-file-select=”” uploader=”uploader” class=”form-control” />

Queue length: {{ uploader.queue.length }}

No files in queue. Start adding some..

Name Size Progress Status Actions
{{ }} {{ item.file.size/1024/1024|number:2 }} MB

<td class=”text-center”>
<span ng-show=”item.isSuccess”>
<em class=”fa fa-check fa-fw”></em>
<span ng-show=”item.isCancel”>
<em class=”fa fa-ban-circle fa-fw”></em>
<span ng-show=”item.isError”>
<em class=”fa fa-times fa-fw”></em>
<td nowrap=””>
<button type=”button” ng-click=”item.upload()” ng-disabled=”item.isReady || item.isUploading || item.isSuccess” class=”btn btn-info btn-xs”>
<span class=”icon-cloud-upload mr”></span>Upload
<button type=”button” ng-click=”item.cancel()” ng-disabled=”!item.isUploading” class=”btn btn-warning btn-xs”>
<span class=”icon-cross mr”></span>Cancel
<button type=”button” ng-click=”item.remove()” class=”btn btn-danger btn-xs”>
<span class=”icon-trash mr”></span>Remove

Queue progress:

<button type=”button” ng-click=”uploader.uploadAll()” ng-disabled=”!uploader.getNotUploadedItems().length” class=”btn btn-info btn-s”>
<span class=”icon-cloud-upload mr”></span>Upload all
<button type=”button” ng-click=”uploader.cancelAll()” ng-disabled=”!uploader.isUploading” class=”btn btn-warning btn-s”>
<span class=”icon-cross mr”></span>Cancel all
<button type=”button” ng-click=”uploader.clearQueue()” ng-disabled=”!uploader.queue.length” class=”btn btn-danger btn-s”>
<span class=”icon-trash mr”></span>Remove all

Angular Controller

Initiate the Fileuploader to object. This object will load the predefined function.

  1. function FileUploadController(FileUploader) {
  2.         var uploader = $scope.uploader = new FileUploader({
  3.             url: ‘server call’
  4.         });
  5.         uploader.filters.push({
  6.             name: ‘customFilter’,
  7.             fn: function (item, options) {
  8.                 return this.queue.length < 10;
  9.             }
  10.         });
  11.         uploader.onWhenAddingFileFailed = function (item, filter, options) {
  12.   ‘onWhenAddingFileFailed’, item, filter, options);
  13.         };
  14.         uploader.onAfterAddingFile = function (fileItem) {
  15.   ‘onAfterAddingFile’, fileItem);
  16.         };
  17.         uploader.onAfterAddingAll = function (addedFileItems) {
  18.   ‘onAfterAddingAll’, addedFileItems);
  19.         };
  20.         uploader.onBeforeUploadItem = function (item) {
  21.   ‘onBeforeUploadItem’, item);
  22.         };
  23.         uploader.onProgressItem = function (fileItem, progress) {
  24.   ‘onProgressItem’, fileItem, progress);
  25.         };
  26.         uploader.onProgressAll = function (progress) {
  27.   ‘onProgressAll’, progress);
  28.         };
  29.         uploader.onSuccessItem = function (fileItem, response, status, headers) {
  30.   ‘onSuccessItem’, fileItem, response, status, headers);
  31.         };
  32.         uploader.onErrorItem = function (fileItem, response, status, headers) {
  33.   ‘onErrorItem’, fileItem, response, status, headers);
  34.         };
  35.         uploader.onCancelItem = function (fileItem, response, status, headers) {
  36.   ‘onCancelItem’, fileItem, response, status, headers);
  37.         };
  38.         uploader.onCompleteItem = function (fileItem, response, status, headers) {
  39.   ‘onCompleteItem’, fileItem, response, status, headers);
  40.         };
  41.         uploader.onCompleteAll = function () {
  42.   ‘onCompleteAll’);
  43.         };
  44.‘uploader’, uploader);

Angular Directive

You can use bootstrap filestyle as angular directive. When you select the image using filestyle, set the element to the <img-crop> directive

  1. .directive(‘filestyle’, filestyle);
  2.     function filestyle() {
  3.         controller.$inject = [‘$scope’‘$element’];
  4.         return {
  5.             restrict: ‘A’,
  6.             controller: controller
  7.         };
  8.         function controller($scope, $element) {
  9.             var options = $;
  10.             options.classInput = $‘classinput’) || options.classInput;
  11.             $element.filestyle(options);
  12.         }
  13.     }

Click F5 button and Run the Application. Now it will appear in the browser and you can see the result.

Output 1


When you selected or dropped into the component, one or more filters are applied. Files which pass all filters are added to the queue.

Output 2


This creates instance uploaders which are copied into the object.

Output 3


Image queue is ready to upload the selected image.


In this article, we have learned about mvc using angular file upload using bootstrap file style. If you have any queries, please tell me through the comments section, because your comments are very valuable.

Happy Coding!…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s