Explore and Learn tutorials and articles on ASP.NET, MVC, .NET Core, SQL Server, C#, VB.NET, AJAX, jQuery, Angular, Entity Framework, Web API, HTML, charts, and more latest technologies.
In this article, I am going to explain how to upload multiple images and files with jquery uploading progress bar using AngularJs in asp.net c# and vb.net. In my previous articles, I explained MVC Angular CRUD Operation Using WEB API 2 With Stored Procedure, and today with this article I will show how you can upload multiple files and images using angular in Asp.net.
Requirement
While we working with any web application sometimes we have some requirements like to upload files, folders,s or images into a database, and for a better user experience obviously, we try to implement such kinds of requirements with a faster way and good user interface. In my case, I got the following requirements from the client-side.
1) Design a Web Page where users can upload files, folders, images.
2) User can select multiple files, folders, images.
3) display a progress bar that indicates the time required to upload selected files in form of a percentage.
5) Add validation for file upload.
6) File/Image size should be 1 MB only, and allow only 1 MB files
4) Show message when all the selected files, folder,s or images from file upload control is successfully Complete.
Implementation
To achieve this requirement we will use angular and I will explain to you how we can create multiple file upload control and for that here, I am going to create an example for demonstration.
Here I will write a script that will validate the size of the file and also inject angular file upload directives and services.
If you analyzed the above code then you can see here I implement validation for file upload and not allows files which is more than 1 MB.
Now, after creating this script you also need to link your script file of angular.min.js, ng-file-upload-shim.min.js, and ng-file-upload.min.js just after <head> tag of your page something like:
If you analyzed above code then we also used AngulerJs progress bar, when the user selects any files/image and submit at that progress bar appear on the screen and shows how much files/images are saved in form of percentage where 100% indicate all the selected files/images saved successfully.
Now, this is the time to add Generic Handler in our project, and we will give the name as UploadHandler. To Add a Generic Handler you can follow these steps.
Step1: Press Mouse Right Click on Name of Your Project.
Step2: Select Add.
Step3: Select Add New Item.
Step4: Select Generic Handler.
Step5: Give the name of your handler.
Step6: Done.
Generic Handler
Add-Generic-Handler
Now, we will write the following code in created Generic Handler UploadHandler.ashx
If You working with C# Then please follow the code described below.
This article explains how you can upload multiple images and files with jquery uploading progress bar using AngularJs in asp.net c# and vb.net, and also explains how you can validate the size of the file. I hope this article helps you, if you have any query then please you can leave your comments in the comment box thank you.
Codingvila provides articles and blogs on web and software development for beginners as well as free Academic projects for final year students in Asp.Net, MVC, C#, Vb.Net, SQL Server, Angular Js, Android, PHP, Java, Python, Desktop Software Application and etc.
Thank you for your valuable time, to read this article, If you like this article, please share this article and post your valuable comments.
Once, you post your comment, we will review your posted comment and publish it. It may take a time around 24 business working hours.
Sometimes I not able to give detailed level explanation for your questions or comments, if you want detailed explanation, your can mansion your contact email id along with your question or you can do select given checkbox "Notify me" the time of write comment. So we can drop mail to you.
If you have any questions regarding this article/blog you can contact us on info.codingvila@gmail.com