Step 1: Create a blank ASP.NET WebForm Project.
Step 2: Right click on the Project ==>select NuGet Package Manager ==> Select DropZone and Download it.
Step 3: Design a WebForm having a file upload control.
Code
- <head runat="server">
- <title></title>
- <script src="scripts/dropzone/dropzone.min.js"></script>
- <link href="scripts/dropzone/basic.min.css" rel="stylesheet" />
- <link href="scripts/dropzone/dropzone.css" rel="stylesheet" />
-
- <script src="scripts/ai.0.15.0-build58334.min.js"></script>
- </head>
- <body>
- <form id="form1" runat="server" class="dropzone">
- <div>
- <div class="fallback">
- <asp:FileUpload ID="file" runat="server" AllowMultiple="true" />
- </div>
- </div>
- </form>
- </body>
- </html>
Step 4: Write the following code in the code behind(.cs) file.
Code
- 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 = "";
-
- if (!string.IsNullOrEmpty(fileName))
- fileExtension = Path.GetExtension(fileName);
-
-
-
- string savepath = Path.Combine(Request.PhysicalApplicationPath, "Files");
- string savefile = Path.Combine(savepath, file.FileName);
- file.SaveAs(savefile);
- }
- }
Step 5: Run the project and select multiple files and drag to the box.
Step 6: 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).