双11狂欢大促

盲盒赢 定制羽绒服

开启惊喜盲盒,抽取你的专属好礼

— 惊喜奖品抢先看 —

把下面的C#代码改成asp的代码(不要.net)

泊客天涯 泊客天涯 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
把下面的C#代码改成asp的代码(不要.net)

<%@ WebHandler Language="C#" Class="upload" %>

using System;
using System.Web;

public class upload : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
HttpRequest request = context.Request;

int c = request.Files.Count;

//接收上传的数据并保存到服务器
for (int i = 0; i < c; i++)
{
HttpPostedFile file = request.Files[i];

string fileName = request["fileName"];
if (string.IsNullOrEmpty(fileName)) fileName = System.IO.Path.GetFileName(file.FileName);

string path = context.Server.MapPath("~/upload/" + fileName);
file.SaveAs(path);
}


string type = request["type"];
string user = request["user"];
string name = request["name"];

//此处返回的JSON字符串为手动拼接,未处理字符串转义等特殊情况,仅作演示
string json = "\"time\":\"" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + "\"";
if (type != null) json += ",\"type\":\"" + type + "\"";
if (user != null) json += ",\"user\":\"" + user + "\"";
if (name != null) json += ",\"name\":\"" + name + "\"";

Finish("{" + json + "}");
}

/// <summary>
/// 完成上传
/// </summary>
/// <param name="json">回调函数参数</param>
private void Finish(string json)
{
HttpResponse Response = HttpContext.Current.Response;

Response.Write(json);
Response.End();
}

public bool IsReusable
{
get
{
return false;
}
}

}
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
泊客天涯
C# 111,129 成员 642,540 内容