upfile.aspx.cs

(开头部分) 3KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class a_upfile : System.Web.UI.Page
{
    private const int MAXPHOTOSIZE = 10240000;//允许最大size
    private const string PHOTOEXTENSION = ".zip|.rar|.txt|.doc|.docx|.xls|.jpg|.gif|.bmp";//允许的格式

    private string _fileNameMemory;//保存图片名称的隐藏域名称

    protected void Page_Load(object sender, EventArgs e)
    {
        InitMember();

        Button1.Attributes.Add("onclick", "return checkInput()");
    }
    private void InitMember()
    {
        _fileNameMemory = string.Empty;
        if (!string.IsNullOrEmpty(Request.QueryString["fn"]))
            _fileNameMemory = Request.QueryString["fn"];
    }
    public static string GetYearAndMonth()
    {
        Random timeSeed = new Random(10);
        DateTime CurrentTime = DateTime.Now;
        return CurrentTime.Year.ToString() + CurrentTime.Month.ToString();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string virtualPath = MapPath("../upfiles/");
        string FileName = Path.GetFileNameWithoutExtension(Uper.PostedFile.FileName);
        string ExtensionName = Path.GetExtension(Uper.PostedFile.FileName);
        string year_month = GetYearAndMonth();
        if (!Directory.Exists(virtualPath + "/" + year_month))
        {
            Directory.CreateDirectory(virtualPath + "/" + year_month);
        }
        
        if (PHOTOEXTENSION.IndexOf(ExtensionName.ToLower()) < 0)
        {
            Response.Write("<script type='text/javascript'>alert('文件格式不正确');</script>");
        }
        else if (Uper.PostedFile.ContentLength == 0)
        {
            Response.Write("<script type='text/javascript'>alert('请选择正确的上传路径');</script>");
        }
        else if (Uper.PostedFile.ContentLength > MAXPHOTOSIZE)
        {
            Response.Write("<script type='text/javascript'>alert('文件太大无法上传');</script>");
        }
        else
        {
            try
            {
后面还有 20 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。