January 25, 2017 08:20 by Peter
In this tutorial, I will show you How To Drag And Upload Multiple Image Files In ASP.NET. First, I create a blank ASP.NET WebForm Project. And then, right click on the Project ==>select NuGet Package Manager ==> Select DropZone and Download it.
Design a WebForm having a file upload control.
<link href="scripts/dropzone/basic.min.css" rel="stylesheet" />
<link href="scripts/dropzone/dropzone.css" rel="stylesheet" />
<form id="form1" runat="server" class="dropzone">
<asp:FileUpload ID="file" runat="server" AllowMultiple="true" />
Write the following code in the code behind(.cs) file.
protected void Page_Load(object sender, EventArgs e)
foreach (string s in Request.Files)
HttpPostedFile file = Request.Files[s];
int fileSizeInBytes = file.ContentLength;
string fileName = file.FileName;
string fileExtension = "";
fileExtension = Path.GetExtension(fileName);
// IMPORTANT! Make sure to validate uploaded file contents, size, etc. to prevent scripts being uploaded into your web app directory
// string savedFileName = Path.Combine(@"..\Files\", Guid.NewGuid().ToString() + fileExtension);
string savepath = Path.Combine(Request.PhysicalApplicationPath, "Files");
string savefile = Path.Combine(savepath, file.FileName);
Run the project and select multiple files and drag to the box.
Drag and drop all the images to the box. It will upload the images and save them to your local folder (here in Files Folder).
European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.