etms/asset/thirdlib/ETMS.WebUI/plugins/umeditor/net/imageUp.ashx
liyuchen d9fba9a316 Remove organization references (de-identify)
- Replace CETC54 references with ETMS
- Replace com.cetc54 package with com.example
- Rename cetc54 directories to etms
- Replace CECT54.WebUI to ETMS.WebUI
- Replace organization names (中国电科54所 -> XX公司)
- Replace internal system URLs (cetc54.com -> example.com)
2026-04-16 17:14:56 +08:00

60 lines
1.9 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ WebHandler Language="C#" Class="imageUp" %>
<%@ Assembly Src="Uploader.cs" %>
using System;
using System.Web;
using System.IO;
using System.Collections;
using System.Collections.Generic;
public class imageUp : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
//上传配置
string pathbase = "upload/"; //保存路径
int size = 10; //文件大小限制,单位mb //文件大小限制单位KB
string[] filetype = { ".gif", ".png", ".jpg", ".jpeg", ".bmp" }; //文件允许格式
string callback = context.Request["callback"];
string editorId = context.Request["editorid"];
//上传图片
Hashtable info;
Uploader up = new Uploader();
info = up.upFile(context, pathbase, filetype, size); //获取上传状态
string json = BuildJson(info);
context.Response.ContentType = "text/html";
if (callback != null)
{
context.Response.Write(String.Format("<script>{0}(JSON.parse(\"{1}\"));</script>", callback, json));
}
else
{
context.Response.Write(json);
}
}
public bool IsReusable
{
get
{
return false;
}
}
private string BuildJson(Hashtable info)
{
List<string> fields = new List<string>();
string[] keys = new string[] { "originalName", "name", "url", "size", "state", "type" };
for (int i = 0; i < keys.Length; i++)
{
fields.Add(String.Format("\"{0}\": \"{1}\"", keys[i], info[keys[i]]));
}
return "{" + String.Join(",", fields) + "}";
}
}