Files
g.hnyhua.cn/Mtxfw.shop/_Admin/Photo_upload2.aspx.cs

55 lines
2.2 KiB
C#
Raw Normal View History

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._admin
{
public partial class Photo_upload2 : Mtxfw.Utility.AdminPage
{
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)
{
if (Request.Files["Photo"] != null)
{
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)
{
string FileName, FileType, Folders;
Folders = config.webUpPath;
FileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Millisecond.ToString();
FileType = Request.Files["Photo"].FileName.Substring(Request.Files["Photo"].FileName.LastIndexOf(".")).ToLower();
string strFilePath = Folders + FileName + FileType;
Request.Files["Photo"].SaveAs(Server.MapPath(strFilePath));
imgurl = FileName + FileType + "|" + Folders + FileName + FileType;
}
else
{
imgurl = "1";
}
}
else
{
imgurl = "0";
}
}
}
}
}
}