把下面的C#代码改成asp的代码(不要.net)
把下面的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;
}
}
}
...全文
相关推荐
VS2010 ASP.NET C# WEB开发(源代码)
ASP.NET C# 开发的门户网站的源代码,实测VS2010打开没问题,使用时用VS2010新建一个网站项目,将所有文件拷入项目文件夹,再用VS2010打开项目即可。
asp.net留言板源代码(C#)
用ASP.NET c#做的留言板源代码
ASP.NET(C#)论坛源代码,采用三层架构
一个调试得相当完善的C#论坛系统,采用三层架构,包括了所有常见的论坛功能,例如后台管理,发帖、回复、上传文件,楼层等,也包括了读取Excel文件的功能。
vS2010 ASP.NET C# WEB开发(源代码)
ASP.NET C# 开发的门户网站的源代码,实测VS2010打开没问题,使用时用VS2010新建一个网站项目,将所有文件拷入项目文件夹,再用VS2010打开项目即可
ASP.NET C# 在线人才招聘系统完整代码
对初学者来学很有帮助,可以演练网站建立的全过程



