作者:htqdw | 来源:互联网 | 2018-06-23 12:13
代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpLoad.aspx.cs" Inherits="UploadifyDemo_UpLoad" %>
上传 | 取消上传
代码如下:
<%@ WebHandler Language="C#" Class="UploadHandler" %>
using System; using System.Web; using System.IO;
public class UploadHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.COntentType= "text/plain"; context.Response.Charset = "utf-8";
HttpPostedFile file = context.Request.Files["Filedata"]; string uploadPath = HttpContext.Current.Server.MapPath(@context.Request["folder"]);
if (file != null) { if (!Directory.Exists(uploadPath)) { Directory.CreateDirectory(uploadPath); } file.SaveAs(Path.Combine(uploadPath, file.FileName)); context.Response.Write("1"); } else { context.Response.Write("0"); } }
public bool IsReusable { get { return false; } } }