zhuguifei
2026-03-10 58402bd5e762361363a0f7d7907153c77dbb819f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
 
namespace NDF.Euploadify
{
    /// <summary>
    /// uploadify 的摘要说明
    /// </summary>
    public class uploadify : IHttpHandler
    {
 
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Charset = "utf-8";
 
            HttpPostedFile file = context.Request.Files["Filedata"];
            string folder = context.Request["folder"],
                id = context.Request["id"],
                value = context.Request["id"];
            string uploadPath = HttpContext.Current.Server.MapPath(folder) + "\\";
 
            if (file != null)
            {
                if (!Directory.Exists(uploadPath))
                {
                    Directory.CreateDirectory(uploadPath);
                }
                file.SaveAs(uploadPath + file.FileName);
 
                //下面这句代码缺少的话,上传成功后上传队列的显示不会自动消失
                context.Response.Write("{ \"id\": \"" + id + "\", \"status\": true, \"message\": \"上传成功!\", \"value\": \"" + value + "\", \"url\": null }");
            }
            else
            {
                context.Response.Write("{ \"id\": null, \"status\": false, \"message\": \"上传失败!\", \"value\": null, \"url\": null }");
            }
        }
 
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}