Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 2, 2014 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/a521bbe24610180d1bbc to your computer and use it in GitHub Desktop.
Save devdays/a521bbe24610180d1bbc to your computer and use it in GitHub Desktop.
Drag and drop file handler client/server -- server code
<%@ WebHandler Language="C#" Class="FileHandler" %>
using System;
using System.Web;
public class FileHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
if (context.Request.Files.Count > 0)
{
HttpFileCollection files = context.Request.Files;
foreach (string key in files)
{
HttpPostedFile file = files[key];
//string fileName = file.FileName;
//fileName = context.Server.MapPath("~/uploads/" + fileName);
string fileName = context.Server.MapPath("~/uploads/" + key);
file.SaveAs(fileName);
}
}
context.Response.ContentType = "text/plain";
context.Response.Write("File(s) uploaded successfully!");
}
public bool IsReusable
{
get { return false; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment