⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upload.aspx.cs

📁 最好用的站点内容管理系统 全部源代码都有
💻 CS
字号:
//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using NetCMS.Content;
using System.Drawing;
using System.Drawing.Imaging;
using NetCMS.Content.Common;

public partial class manage_Templet_Upload : NetCMS.Web.UI.DialogPage
{
    public manage_Templet_Upload()
    {
        BrowserAuthor = EnumDialogAuthority.ForAdmin;
    }
    string str_returnpath = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.CacheControl = "no-cache";
        string upfiletype = Request.QueryString["upfiletype"];
        if (upfiletype == "templets") { this.isWater.Visible = false; }

        string Type = Request.QueryString["Type"];                              //取得参数以判断是否上传文件
        if (Type == "Upload")
        {
            string Path = Server.UrlDecode(Request.QueryString["Path"]);                          //取得上传文件所要保存的路径
            string localSavedir = NetCMS.Config.UIConfig.dirFile;
            string localtemplet = NetCMS.Config.UIConfig.dirTemplet;
            string dimmdir = NetCMS.Config.UIConfig.dirDumm;
            string _Tmpdimmdir = "";
            string UDir = "";
            if (dimmdir.Trim() != "") { _Tmpdimmdir = "/" + dimmdir; }
            ///还未判断分站情况///
            str_returnpath = _Tmpdimmdir + "/" + localSavedir + "/" + Path;
            switch (upfiletype)
            {
                case "templets":
                    Path = Server.MapPath(_Tmpdimmdir + "/" + localtemplet + "/" + Path);
                    break;
                case "templet":
                    Path = Server.MapPath(_Tmpdimmdir + "/" + localtemplet + "/" + Path);
                    break;
                case "files":
                    Path = Server.MapPath(_Tmpdimmdir +"/" + localSavedir + "/" + Path);
                    break;
                default :
                    Path = Server.MapPath(_Tmpdimmdir + "/" + localSavedir + "/" + Path);
                    break;
            }
            if (Path != "" && Path != null && Path != string.Empty)             //判断路径是否正确
            {
                NetCMS.Content.Common.UpLoad tt = new NetCMS.Content.Common.UpLoad();   //实例化上传类
                NetCMS.Content.Upload up = new NetCMS.Content.Upload();
                DataTable dt = up.getUploadInfo();
                string utype = "jpg,gif,bmp,png,swf";
                int usize = 500;
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                    {
                        utype = dt.Rows[0]["UpfilesType"].ToString();
                        usize = int.Parse(dt.Rows[0]["UpFilesSize"].ToString());
                    }
                    dt.Clear(); dt.Dispose();
                }
                tt.FileLength = usize;                   //为类参数赋值,此为上传文件允许的大小值,单位kb
                tt.Extension = utype;                    //为类参数赋值,此为上传文件允许上传的类型,以","号分隔
                string _Ytmp = DateTime.Now.Year + "-" + DateTime.Now.Month;
                if (this.yearDirTF.Checked) { tt.SavePath = Path + _Ytmp + "\\"; }
                else{tt.SavePath = Path;}
                int _num = 0;
                if (this.CheckFileTF.Checked) { _num = 1; }
                tt.PostedFile = file.PostedFile;         //为类参数赋值,此为上传文件所读取的上传控件值
                string[] ReturnStr = tt.Upload(_num,1).Split('$');
                //生成水印
                if (ReturnStr[1] == "1")
                {
                    string _fileNamePath = "";
                    string ResultSTR = "";
                    string s_rpath = Server.UrlDecode(Request.QueryString["Path"]);
                    string s_rppath = Server.UrlDecode(Request.QueryString["ParentPath"]);
                    s_rpath = s_rpath.Replace("\\", "\\\\");
                    s_rppath = s_rppath.Replace("\\", "\\\\");
                    if (upfiletype != "templets")
                    {
                        if (this.isWater.Checked)
                        {
                            if (NetCMS.Global.Current.SiteID != "0") 
                            {
                                UDir = _Tmpdimmdir + "/" + NetCMS.Config.UIConfig.dirSite + "/" + NetCMS.Global.Current.SiteID + "/" + localSavedir + "/" + Server.UrlDecode(Request.QueryString["Path"]);
                            }
                            else 
                            {
                                UDir = _Tmpdimmdir + "/" + localSavedir + "/" + Server.UrlDecode(Request.QueryString["Path"]);
                            }
                            UDir = UDir.Replace("//", "/");

                            _fileNamePath = UDir + "/" + ReturnStr[0];
                            if (this.yearDirTF.Checked)
                            {
                                _fileNamePath = UDir + "/" + _Ytmp + "/" + ReturnStr[0];
                            }

                            NetCMS.Content.Sys Sys = new NetCMS.Content.Sys();
                            DataTable dt_sys = Sys.WaterStart();

                            if (dt_sys.Rows[0]["PrintTF"].ToString() == "1")
                            {
                                if (dt_sys.Rows[0]["PrintPicTF"].ToString() == "7")
                                {
                                    FSImage fd = new FSImage(0, 0, Server.MapPath(_fileNamePath));
                                    fd.Quality = 100;
                                    fd.Title = dt_sys.Rows[0]["PrintWord"].ToString();
                                    fd.FontSize = Convert.ToInt32(dt_sys.Rows[0]["Printfontsize"].ToString());
                                    if (dt_sys.Rows[0]["PrintBTF"].ToString() == "1")
                                        fd.StrStyle = FontStyle.Bold;
                                    fd.FontColor = ColorTranslator.FromHtml("#" + dt_sys.Rows[0]["Printfontcolor"].ToString());
                                    fd.BackGroudColor = Color.White;
                                    fd.FontFamilyName = dt_sys.Rows[0]["Printfontfamily"].ToString();
                                    fd.Waterpos = dt_sys.Rows[0]["PrintPosition"].ToString();
                                    fd.Watermark();
                                }
                                else
                                {
                                    string s_picsize = dt_sys.Rows[0]["PrintPicsize"].ToString();
                                    string[] a_picsize = s_picsize.Split('|');
                                    FSImage fd = new FSImage(0, 0, Server.MapPath(_fileNamePath));
                                    fd.Waterpos = dt_sys.Rows[0]["PrintPosition"].ToString();
                                    fd.Height = Convert.ToInt32(a_picsize[0].ToString());
                                    fd.Width = Convert.ToInt32(a_picsize[1].ToString());
                                    fd.WaterPath = createJs.ReplaceDirfile(Server.MapPath(dimmdir + dt_sys.Rows[0]["PintPicURL"].ToString()));
                                    fd.WaterPicturemark();
                                }
                            }
                            dt_sys.Clear(); dt_sys.Dispose();
                        }
                        Response.Write("<script language=\"javascript\">try{ window.opener.insertHTMLEdit('" + str_returnpath + "/" + ReturnStr[0] + "') ; }catch(err){};try{window.opener.ListGo('" + s_rpath + "','" + s_rppath + "');}catch(err){};alert('文件上传成功!');window.close();</script>");
                        Response.End();
                    }
                    else { ResultSTR = "<script language=\"javascript\">window.opener.ListGo('" + s_rpath + "','" + s_rppath + "');alert('" + ReturnStr[0] + "文件上传成功!');window.close();</script>"; }
                    Response.Write(ResultSTR);
                    Response.End();
                }
                else
                {
                    PageError("" + ReturnStr[0] + "<li><a href=\"javascript:history.back()\"><font color=\"red\">返回</font></a>&nbsp;&nbsp;&nbsp;<a href=\"javascript:window.close()\"><font color=\"red\">关闭窗口</font></a></li>", "");
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -