addproducts.aspx.cs

(开头部分) 2KB

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

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class addproducts : System.Web.UI.Page
{
    string imgPath;
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        bool fileOK = false;
        string path = Server.MapPath("~/img/");
        if (FileUpload1.HasFile)
        {
            String fileExtension = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
            String[] allowedExtensions = { ".gif", ".png", ".bmp", ".jpg" };
            for (int i = 0; i < allowedExtensions.Length; i++)
            {
                if (fileExtension == allowedExtensions[i])
                {
                    fileOK = true;
                }
            }
        }
        if (fileOK)
        {
            try
            {
                FileUpload1.SaveAs(path + FileUpload1.FileName);
                Session["path"] = FileUpload1.FileName;
                imgPath = path + FileUpload1.FileName;
                lbMessage1.Text = "文件上传成功.";
                lbMessage2.Text = "<b>原文件路径:</b>" + FileUpload1.PostedFile.FileName + "<br />" +
                              "<b>文件大小:</b>" + FileUpload1.PostedFile.ContentLength + "字节<br />" +
                              "<b>文件类型:</b>" + FileUpload1.PostedFile.ContentType + "<br />";
            }
            catch (Exception ex)
            {
                lbMessage1.Text = "文件上传不成功.";
            }
        }
        else
        {
            lbMessage1.Text = "只能够上传图片文件.";
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string path = "~/img/";
        imgPath = path + Session["path"];
后面还有 13 行代码,解锁后查看完整代码

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

AI 解读 AI

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

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