在asp.net中使用dropzone.js

因为几天我试图用拖放界面实现多个文件上传。 我搜索了很多,最后从http://www.dropzonejs.com/找到了我的确切要求

我从上面的网站尝试了相同的步骤。 但是,我无法在我的aspx页面中实现此dropzonefunction。

假设您使用的是Web窗体,则需要实现一个页面来读取已发布的文件数据并将其保存到文件中。

示例.ASPX

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Mvc4Application_Basic.WebForm1" %>         

代码隐藏示例

  public partial class WebForm1 : System.Web.UI.Page { 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 = Request.Headers["X-File-Name"]; string fileExtension = ""; if (!string.IsNullOrEmpty(fileName)) 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(@"C:\Temp\", Guid.NewGuid().ToString() + fileExtension); file.SaveAs(savedFileName); } } } 

如果您使用的是MVC,请参阅此https://stackoverflow.com/a/15670033/2288997