Files
g.hnyhua.cn/Mtxfw.shop/Member_Photo_upload.aspx.cs
2026-02-07 15:48:27 +08:00

130 lines
6.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using Newtonsoft.Json;
using System.IO;
namespace Mtxfw.shop
{
public partial class Member_Photo_upload : Mtxfw.Utility.MemberBase
{
public string strQX = "", imgurl = "", imgurl2 = "", imgPath = "";
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config();
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!Page.IsPostBack)
{
bool IFUpload = false;
if (Request.Files["Photo"] != null && Request.QueryString["yanse"] != null)
{
if (Session["jiaoyouPhoto"] != null)
{
string[] strjiaoyouPhotoA = Session["jiaoyouPhoto"].ToString().Split('|');
if (strjiaoyouPhotoA.Length > 100)
{
IFUpload = true;
}
}
if (IFUpload)
{
imgurl = "2";
}
else
{
string strContentType = Request.Files["Photo"].ContentType.ToLower();
int intContentLength = Request.Files["Photo"].ContentLength;
if (strContentType.IndexOf("jpg") != -1 || strContentType.IndexOf("jpeg") != -1 || strContentType.IndexOf("gif") != -1 || strContentType.IndexOf("png") != -1 || strContentType.IndexOf("bmp") != -1)
{
if (intContentLength < 102400 * 20)
{
Mtxfw.Utility.UploadFile upload = new Mtxfw.Utility.UploadFile(Request.Files["Photo"], config.webUpPath, config.webUpType, int.Parse(config.webUpSize));
if (upload.StatrUpFile())
{
if (Session["jiaoyouPhoto"] != null)
{
string strjiaoyouPhoto = Session["jiaoyouPhoto"].ToString();
strjiaoyouPhoto += upload.UploadPath + "|";
Session["jiaoyouPhoto"] = strjiaoyouPhoto;
}
else
{
string strjiaoyouPhoto = upload.UploadPath + "|";
Session["jiaoyouPhoto"] = strjiaoyouPhoto;
}
}
string stryanseoption = "";
if (Request.QueryString["yanse"] != "")
{
string stryanse = Request.QueryString["yanse"].ToString().Replace(",","#");
string[] Ayanse = stryanse.Split('|');
for (int i = 0; i < Ayanse.Length; i++)
{
if (Ayanse[i] != "")
{
string[] stra = Ayanse[i].Split('#');
stryanseoption += "<option value='" + Ayanse[i] + "'>" + stra[0] + "</option>";
}
}
}
if (Session["jiaoyouPhoto"] != null)
{
imgurl = "";
string[] strjiaoyouPhotoA = Session["jiaoyouPhoto"].ToString().Split('|');
for (int i = 0; i < strjiaoyouPhotoA.Length; i++)
{
if (strjiaoyouPhotoA[i] != "")
{
string[] strPhoto = strjiaoyouPhotoA[i].Split(',');
imgurl += "<li id='picli" + i + "'><img class='pic' src='" + Mtxfw.Utility.Common.GetCoverPic(strPhoto[0], "100x100", "cut") + "' width='100'/><a href=javascript:DeletePic('" + strjiaoyouPhotoA[i] + "'," + i + ")>删除</a>";
if (i == 0)
{
imgurl += "&nbsp;已设为封面";
}
else
{
imgurl += "&nbsp;<a href=javascript:SetPic('" + strjiaoyouPhotoA[i] + "'," + i + ")>设为封面</a>";
}
if (stryanseoption != "")
{
string stryanseoption2 = stryanseoption;
if (strPhoto.Length == 2)
{
if (strPhoto[1] != "")
{
stryanseoption2 = stryanseoption.Replace("value='" + strPhoto[1] + "'", "value='" + strPhoto[1] + "' selected");
}
}
imgurl += "<br><select id='select_yanse_" + i + "'>" + stryanseoption2 + "</select>";
}
imgurl += "</li>";
}
}
}
}
else
{
imgurl = "1";
}
}
else
{
imgurl = "0";
}
}
}
}
}
}
}