Learn MVC Using Angular File Upload

Introduction

This article demonstrates learning MVC using Angular File Upload and Bootstrap Filestyle 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 a file is added to the queue, it creates a file item and uploader options are into this object. After, the items in the queue are ready for uploading.

Features

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

Below are the steps that allow you to use Angular File Upload in Angular JS and MVC.

  • Create an MVC Project.
  • Configure Angular File Upload and Bootstrap Filestyle.
  • Work in Angular File Upload.

Create an MVC Project

Open Visual Studio 2017.

MVC

Go to New menu >Click New and Project. Now it will open the New Project Window.

MVC

You can select ASP.NET Web Application on Framework 4.5. Enter the name of the project in tje “Solution name” text box and then click OK.

MVC

One more window should appear. Select MVC Template in this pop-up and click OK. Now start cropping your image.

Configure Angular File Upload and Bootstrap Filestyle

Right click on the project and go to the NuGet package manager. Then search ‘angularfileupload’ in the Browse tab and install it.

MVC

OR you can download the plugins from here:

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

Link your Angular configurable file here, using whatever name you gave it.

Angular Module

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

Work in Angular Image Upload

Using a Bootstrap Filestyle directive, create a single uploading attribute.

HTML Code

Angular Controller

Initiate the Fileuploader as an object. This object will load the predefined function.

Angular Directive

You can use Bootstrap Filestyle as an Angular directive. When you select the image using Filestyle, set the element using the <img-crop> directive.

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

Output 1

MVC

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

Output 2

MVC

This creates instance uploaders which are copied into the object.

Output 3

MVC

Image queue is ready to upload the selected image.

Conclusion

In this article, we have learned about MVC using Angular File Upload and Bootstrap File Style. If you have any queries, please tell me through the comments section, because your comments are very valuable.

Happy Coding!

Author Profile

Thiruppathi Rengasamy
I 'm a .Net Developer & Blogger. And also I'm working as senior software engineer in Microsoft Technologies for 5+ Years.I would like to spend my precious time in writing articles, research in .Net technologies and to learn new technologies. I have been awarded as C# Corner MVP & DZone MVB.
Show Buttons
Hide Buttons