TZ.Web/wiki/upload.aspx.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections;
using System.Configuration;
using System.Data;
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.Text;
using System.Net;
using System.IO;
using TZ.Common;
public partial class wiki_upload : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpFileCollection files = Request.Files;
if (files != null && files.Count > 0)
{
HttpPostedFile file = files[0];
fileSaveAs(file, "upload");
}
}
/// <summary>
/// 上传图片
/// </summary>
/// <param name="page"></param>
/// <param name="_postedFile"></param>
/// <param name="_filePath"></param>
/// <returns></returns>
public void fileSaveAs(HttpPostedFile _postedFile, string _filePath)
{
try
{
string _fileExt = _postedFile.FileName.Substring(_postedFile.FileName.LastIndexOf(".") + 1);
//验证合法的文件
if (!CheckFileExt("BMP|JPEG|JPG|GIF|PNG|ZIP|RAR|MP4|FLV", _fileExt))
{
string msg = "不允许上传" + _fileExt + "类型的文件!";
Response.Write("{\"status\": 0, \"msg\": \"" + msg + "\"}");
Response.End();
}
else
{
//随机文件名
string _fileName = DateTime.Now.ToString("yyyyMMddHHmmssff") + "." + _fileExt;
//检查保存的路径 是否有/开头结尾
if (_filePath.StartsWith("/") == false) _filePath = "/" + _filePath;
if (_filePath.EndsWith("/") == false) _filePath = _filePath + "/";
//按日期归类保存
string _datePath = DateTime.Now.ToString("yyyyMMdd") + "/";
_filePath += _datePath;
//获得要保存的文件路径
string serverFileName = _filePath + _fileName;
//物理完整路径
string toFileFullPath = HttpContext.Current.Server.MapPath("~" + _filePath);
后面还有 33 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
