WebMvc/Content/Controls/Files/upload.ashx
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
<%@ WebHandler Language="C#" Class="Upload" %>
using System;
using System.Web;
using System.IO;
using System.Web.SessionState;
public class Upload : IHttpHandler, IReadOnlySessionState
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
string str1 = context.Request["str1"];
string str2 = context.Request["str2"];
if (!Check.CheckLogin(false))
{
context.Response.Write("您不能上传文件");
context.Response.End();
return;
}
//接收上传后的文件
HttpPostedFile file = context.Request.Files["Filedata"];
if (false && !"".Contains(Path.GetExtension(file.FileName), StringComparison.CurrentCultureIgnoreCase))
{
context.Response.Write("您上传的文件类型不被允许");
context.Response.End();
return;
}
//获取文件的保存路径
string uploadPath;
string uploadFullPath = context.Server.MapPath(getFilePath(out uploadPath));
//判断上传的文件是否为空
if (file != null)
{
if (!Directory.Exists(uploadFullPath))
{
Directory.CreateDirectory(uploadFullPath);
}
//保存文件
string newFileName = getFileName(uploadFullPath, file.FileName);
string newFileFullPath = uploadFullPath + newFileName;
try
{
int fileLength = file.ContentLength;
file.SaveAs(newFileFullPath);
context.Response.Write("1|" + (uploadPath + newFileName) + "|" + fileLength.ToString("###,###") + "|" + newFileName);
//context.Response.Write(newFileFullPath);
}
catch
{
context.Response.Write("上传文件发生了错误");
}
}
else
{
context.Response.Write("上传文件为空");
后面还有 37 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
