Created
December 2, 2014 05:12
-
-
Save devdays/a521bbe24610180d1bbc to your computer and use it in GitHub Desktop.
Drag and drop file handler client/server -- server code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ 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