admin/pic_upload.aspx.cs
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Data.Sql;
using System.IO;
public partial class admin_pic_upload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.PostedFile.FileName == string.Empty)
{
Response.Write("<script>alert('请选择要上传的文件!');</script>");
}
else
{
//获取要上传的文件的信息
string filepath = FileUpload1.PostedFile.FileName;//文件路径
string filename = TextBox1.Text.Trim();
string oldfilename = filepath.Substring(filepath.LastIndexOf("\\") + 1);//文件名
string FileExtension = Path.GetExtension(oldfilename); //文件的扩展名
int filelength = (int)oldfilename.Length;//文件名长度
//随机生成文件名
Random Rnd = new Random();
int strRnd = Rnd.Next(1, 99);
string newfilename = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString()
+ DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() +
DateTime.Now.Second.ToString() + strRnd.ToString() + FileExtension.ToLower();
//将文件上传到以当前日期命名的文件夹中
bool FileUploadPathExists = File.Exists(Server.MapPath("UpLoad"));
//指定文件夹不存在,如果不存在就创建该文件夹
if (!FileUploadPathExists)
{
Directory.CreateDirectory(Server.MapPath("UpLoad"));
}
//保存上传的文件
string savapath = Server.MapPath("UpLoad" );//保存路径
string savapath1 = "UpLoad" + "\\" + newfilename;//保存路径
FileUpload1.PostedFile.SaveAs(savapath + "\\" + newfilename);
//连接数据库字符串
string connstr = ConfigurationManager.ConnectionStrings["yutian66"].ConnectionString;
后面还有 29 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。