LK.Shop.Web/Inc/Upload_Base.aspx.cs
(开头部分) 6KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
namespace LK.Shop.Web.Inc
{
public partial class Upload_Base : System.Web.UI.Page
{
LK.Shop.BLL.Upload uploadBll = new BLL.Upload();
LK.Shop.Model.Upload uploadModel = new Model.Upload();
protected void Page_Load(object sender, EventArgs e)
{
this.FileUpload.Attributes.Add("onchange", "do_fileselect('" + Request.QueryString["rname"] + "');");
this.Button_up.Attributes.Add("onclick", "return do_isup('" + Request.QueryString["rname"] + "');");
this.Button_up.Attributes.Add("disabled", "disabled");
}
protected void Button_up_Click(object sender, EventArgs e)
{
// 初始化变量
string inputname = "FileUpload";//表单文件域name
string rname = Request.QueryString["rname"];//返回信息的input
string attachdir = "/upload"; // 上传文件保存路径,结尾不要带/
int dirtype = 1; // 1:按天存入目录 2:按月存入目录 3:按扩展名存目录 建议使用按天存
int maxattachsize = Convert.ToInt32(2) * 1024 * 1024; // 最大上传大小,默认是2M
string upext = "zip,rar,txt,doc,docx,xls,xlsx,jpg,jpeg,gif,png,bmp,swf,wmv,avi,wma,mp3,mid"; // 上传扩展名
byte[] file; // 统一转换为byte数组处理
string localname = "";
string backmsg = "";
HttpFileCollection filecollection = Request.Files;
HttpPostedFile postedfile = filecollection.Get(inputname);
// 读取原始文件名
localname = postedfile.FileName;
// 初始化byte长度.
file = new Byte[postedfile.ContentLength];
// 转换为byte类型
System.IO.Stream stream = postedfile.InputStream;
stream.Read(file, 0, postedfile.ContentLength);
stream.Close();
filecollection = null;
if (file.Length == 0)
{
backmsg = "0|请选择相应的上传文件.";
}
else
{
if (file.Length > maxattachsize)
{
backmsg = "0|文件大小超过" + maxattachsize + "字节.";
}
后面还有 87 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
