SenBiTeSolution.UI/ManageWeb/AddAnLi.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;
using SenBiTeSolution.Common;
using SenBiTeSolution.DAL;

namespace SenBiTeSolution.UI.ManageWeb
{
    public partial class AddAnLi : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        //添加
        protected void btn_Add_Click(object sender, EventArgs e)
        {
            int len = FileUpload1.PostedFile.ContentLength;     //文件大小
            if (len == 0)
            {
                MessageBox.Show(this.Page, "产品图片不可为空!");
                return;
            }

            string fileName = FileUpload1.PostedFile.FileName;      //文件名
            fileName = Path.GetFileName(fileName);
            string suffixName = fileName.Substring(fileName.LastIndexOf(".") + 1);        //上传文件后缀名
            suffixName = suffixName.ToLower();   //将上传文件后缀名转为小写
            string type = "jpg|gif|png";       //指定上传文件类型的字符串,以“|”分隔
            string[] suffix = type.Split('|');

            bool isExist = false;
            foreach (string item in suffix)
            {
                if (item == suffixName)
                {
                    isExist = true;
                }
            }

            if (!isExist)
            {
                MessageBox.Show(this.Page, "后缀名为" + suffixName + "的文件不支持上传!");
                return;
            }

            if (len > 1024 * 1024 * 20)
            {
                MessageBox.Show(this.Page, "上传文件不可超过20M!");
                return;
            }

            string imgFilePath = Server.MapPath("~/ProductImg");
            string imgName = System.DateTime.Now.ToString().Replace("/", "").Replace("-", "").Replace(":", "").Replace(" ", "") + "." + suffixName;
后面还有 39 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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