WebApplication/Upload.ashx.cs

(开头部分) 1KB

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Newtonsoft.Json;

namespace WebApplication
{
    /// <summary>
    /// Upload 的摘要说明
    /// </summary>
    public class Upload : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpPostedFile file = context.Request.Files[0];
            string uploadPath = context.Request.MapPath("~/upload/file/");
            if (file != null)
            {
                //新文件名

                string filename = Guid.NewGuid().ToString("N") + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(uploadPath + filename);
                ReturnList.ResultInfo info = new ReturnList.ResultInfo();
                info.errorcode = 0;
                info.msg = "OK";
                info.url = "/upload/file/" + filename;
                string str = JsonConvert.SerializeObject(info);
                context.Response.Write(str);

                //context.Response.Write();
            }
            else
            {
                ReturnList.ResultInfo info = new ReturnList.ResultInfo();
                info.errorcode = 1;
                info.msg = "Error";
                info.url = "";
                string str = JsonConvert.SerializeObject(info);
                context.Response.Write(str);
            }
        }
        public class ReturnList
        {
            public class ResultInfo
            {
                public int errorcode { get; set; }
                public string msg { get; set; }
                public string url { get; set; }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
后面还有 3 行代码,购买后查看完整代码

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

AI 解读 AI

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

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