示例#1
0
        private void BindData(List <CMSFileManage.FileFolderInfo> files, CMSFileManage.FileManagerProcessor fileManage)
        {
            if (files == null)
            {
                return;
            }

            folderNum = fileManage.FolderNum;
            fileNum   = fileManage.FileNum;

            List <CMSFileManage.FileFolderInfo> Result = new List <CMSFileManage.FileFolderInfo>();

            int pageIndex = 1;

            if (!string.IsNullOrEmpty(Request.QueryString["pg"]))
            {
                pageIndex = int.Parse(Request.QueryString["pg"]);
            }
            if (pageIndex < 1)
            {
                pageIndex = 1;
            }
            int    pageSize   = 20;
            int    startIndex = (pageIndex - 1) * pageSize;
            string imgExt     = ".jpg,.bmp,.jpeg,.gif,.png";
            string imgWidth   = string.Empty;
            string imgHeight  = string.Empty;
            int    resultInt  = 0;

            for (int i = startIndex; i < startIndex + pageSize && i < files.Count; i++)
            {
                Result.Add(files[i]);
                imgWidth  = "";
                imgHeight = "";
                if (imgExt.IndexOf(files[i].Ext.ToLower()) != -1 && files[i].Type == "file")
                {
                    System.Drawing.Image image = System.Drawing.Image.FromFile(Server.UrlDecode(files[i].FullName));
                    imgWidth  = image.Width.ToString();
                    imgHeight = image.Height.ToString();
                    Result[resultInt].ImgWidth  = imgWidth;
                    Result[resultInt].ImgHeight = imgHeight;
                }
                resultInt++;
            }

            rptList.DataSource = Result;
            rptList.DataBind();
            KingTop.Common.Split split = new KingTop.Common.Split();
            string pageTemplate        = "<li><a href=\"{$FirstPageUrl}\"  class=\"text\">首页</a></li><li><a href=\"{$PrevPageUrl}\" class=\"text\">上页</a></li>[HQB.Loop]<li><a href=\"{$PageUrl}\">{$PageIndex}</a></li><li>[$$$$]</li><li><a href=\"{$CurrentPageUrl}\" class=\"hover02\">{$CurrentPageIndex}</a></li>[/HQB.Loop]<li><a href=\"{$NextPageUrl}\" class=\"text\">下页</a></li><li><a href=\"{$LastPageUrl}\" class=\"text\">末页</a></li>";
            string url = "";

            PageStr = KingTop.Common.Split.GetHtmlCode(url, pageTemplate, 2, pageIndex, pageSize, files.Count, false);
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 文件上传
            uploadobj = Upload.GetConfig(GetUploadImgPath); //上传设置信息
            if (uploadobj.IsEnableUpload != "1")            // 判断是否允许上传
            {
                Response.Write("已经关闭上传功能,请联系管理员");
                Response.End();
            }
            MaxSize  = int.Parse(uploadobj.UploadImageSize) / 1024;
            AllowExt = uploadobj.UploadImageType;
            AllowExt = "*." + AllowExt.Replace("|", ";*.");
            string   imgSet = "0";
            string[] arr    = AllowExt.Split(';');
            for (int i = 0; i < arr.Length; i++)
            {
                if (i == 9)
                {
                    AllowExtMemo += "<br>";
                }
                if (i > 0)
                {
                    AllowExtMemo += ";";
                }
                AllowExtMemo += arr[i];
            }

            sitedir = SiteDir;

            if (uploadobj.IsEnableWatermark == "1")
            {
                imgSet           = "1";
                chkWater.Checked = true;
                if (uploadobj.WatermarkType == "0")
                {
                    WaterDivId.InnerHtml = "<br>水印文字为:<br><font color=red>" + uploadobj.WatermarkText + "</font>";
                }
                else
                {
                    if (System.IO.File.Exists(Server.MapPath("/" + uploadobj.WatermarkPic)))
                    {
                        WaterDivId.InnerHtml = "水印图片:<br><img src='/" + uploadobj.WatermarkPic + "' style='width:100px;border:1px solid #CCCCCC' alt='水印图片' title='水印图片'>";
                    }
                    else
                    {
                        WaterDivId.InnerHtml = "<font color=red>注,请上传水印图片,图片位置为:<br>/" + uploadobj.WatermarkPic + "</font>";
                    }
                }
            }
            txtWidth.Value  = uploadobj.ThumbnailWidth;
            txtHeight.Value = uploadobj.ThumbnailHeight;
            paramKey        = DateTime.Now.ToString("yyyyMMddhhmmsfff");
            imgSet          = uploadobj.ThumbnailWidth + "," + uploadobj.ThumbnailHeight + "," + imgSet;
            paramValue      = imgSet;
            #endregion

            #region  择文件
            // 操作处理
            CMSFileManage.FileManagerProcessor fileManage = new CMSFileManage.FileManagerProcessor(Request.QueryString["act"]);
            builder.Append(fileManage.Value);

            string upFileType      = Request.QueryString["type"];
            string RootUploadFiles = string.Empty;
            string thisSiteDir     = "/" + SiteDir;
            //文件不分站点保存
            thisSiteDir = "";
            switch (upFileType)
            {
            case "image":
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/images/");
                break;

            case "file":
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/files/");
                break;

            case "media":
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/medias/");
                break;

            default:
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/files/");
                break;
            }

            if (string.IsNullOrEmpty(folderPath))
            {
                folderPath = RootUploadFiles;
            }
            else if (folderPath.IndexOf(":") == -1)
            {
                folderPath = Server.MapPath("/" + folderPath);
            }


            // 组合路径, 快速导航
            string comePath = "";
            foreach (string q in folderPath.Split('\\'))
            {
                comePath += q;
                currPath.AppendFormat("<a href=\"image.aspx?path={1}&type={2}\">{0}</a>", q + "\\", comePath, upFileType);
                comePath += "\\";
            }

            // 返回上级
            //if (new DirectoryInfo(folderPath).Root.ToString().Replace("\\", "") != folderPath.ToUpper())
            if (RootUploadFiles.ToLower().IndexOf(folderPath.ToLower()) == -1)
            {
                string previousFolder = folderPath.Substring(0, folderPath.LastIndexOf("\\"));
                backHtml = "<a href=\"image.aspx?path=" + Server.UrlEncode(previousFolder) + "&type=" + upFileType + "\"><img src=\"../video/folderback.gif\" alt=\"返回上级\" align=\"absmiddle\"  border=0/> 返回上级</a>";
            }
            else
            {
                folderPath += "\\";
            }
            folderPath = folderPath.Replace("\\\\", "\\");
            // 绑定数据
            fileManage = new CMSFileManage.FileManagerProcessor();
            List <CMSFileManage.FileFolderInfo> files = fileManage.GetDirectories(folderPath, "filesmanage.aspx");

            if (fileManage.Access)
            {
                BindData(files, fileManage);
            }
            else
            {
                builder.Append("无权限访问该目录. <a href='javascript:history.go(-1);' style='font-weight: normal'>后退</a>");
            }


            if (builder.ToString() != "")
            {
                string builderResult = builder.ToString();
                builder = new System.Text.StringBuilder("");
                builder.AppendFormat("<script type=\"text/javascript\">$(\"#tips\").show(); $(\"#tipsMsg\").html(\"{0}\"); </script>", builderResult.Replace(@"\", @"\\"));
            }
            #endregion
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 文件上传
            uploadobj = Upload.GetConfig(GetUploadImgPath); //上传设置信息
            if (uploadobj.IsEnableUpload != "1")            // 判断是否允许上传
            {
                Response.Write("已经关闭上传功能,请联系管理员");
                Response.End();
            }
            MaxSize  = int.Parse(uploadobj.UploadMediaSize) / 1024;
            AllowExt = uploadobj.UploadMediaType;
            AllowExt = "*." + AllowExt.Replace("|", ";*.");
            sitedir  = SiteDir;
            #endregion

            #region  择文件
            // 操作处理
            CMSFileManage.FileManagerProcessor fileManage = new CMSFileManage.FileManagerProcessor(Request.QueryString["act"]);
            builder.Append(fileManage.Value);

            string upFileType      = Request.QueryString["type"];
            string RootUploadFiles = string.Empty;
            string thisSiteDir     = "/" + SiteDir;
            //文件不分站点保存
            thisSiteDir = "";
            switch (upFileType)
            {
            case "image":
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/images/");
                break;

            case "file":
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/files/");
                break;

            case "media":
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/medias/");
                break;

            default:
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/files/");
                break;
            }

            if (string.IsNullOrEmpty(folderPath))
            {
                folderPath = RootUploadFiles;
            }
            else if (folderPath.IndexOf(":") == -1)
            {
                folderPath = Server.MapPath("/" + folderPath);
            }


            // 组合路径, 快速导航
            string comePath = "";
            foreach (string q in folderPath.Split('\\'))
            {
                comePath += q;
                currPath.AppendFormat("<a href=\"video.aspx?path={1}&type={2}\">{0}</a>", q + "\\", comePath, upFileType);
                comePath += "\\";
            }

            // 返回上级
            //if (new DirectoryInfo(folderPath).Root.ToString().Replace("\\", "") != folderPath.ToUpper())
            if (RootUploadFiles.ToLower().IndexOf(folderPath.ToLower()) == -1)
            {
                string previousFolder = folderPath.Substring(0, folderPath.LastIndexOf("\\"));
                backHtml = "<a href=\"video.aspx?path=" + Server.UrlEncode(previousFolder) + "&type=" + upFileType + "\"><img src=\"folderback.gif\" alt=\"返回上级\" align=\"absmiddle\"  border=0/> 返回上级</a>";
            }
            else
            {
                folderPath += "\\";
            }
            folderPath = folderPath.Replace("\\\\", "\\");
            // 绑定数据
            fileManage = new CMSFileManage.FileManagerProcessor();
            List <CMSFileManage.FileFolderInfo> files = fileManage.GetDirectories(folderPath, "filesmanage.aspx");

            if (fileManage.Access)
            {
                BindData(files, fileManage);
            }
            else
            {
                builder.Append("无权限访问该目录. <a href='javascript:history.go(-1);' style='font-weight: normal'>后退</a>");
            }


            if (builder.ToString() != "")
            {
                string builderResult = builder.ToString();
                builder = new System.Text.StringBuilder("");
                builder.AppendFormat("<script type=\"text/javascript\">$(\"#tips\").show(); $(\"#tipsMsg\").html(\"{0}\"); </script>", builderResult.Replace(@"\", @"\\"));
            }
            #endregion
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region   文件
            //pFile=&FormName=theForm&ElementName=HQB_MultiFile_img1&ControlType=2&UpType=image&ExtType=&MaxSize=4096&GetSizeControl=img1&ThumbWidth=125&ThumbHeight=125

            uploadobj           = Upload.GetConfig(GetUploadImgPath);      //上传设置信息
            this.UpType         = Request.QueryString["UpType"].ToLower(); //上传类型
            this.ExtType        = Request.QueryString["ExtType"];          //用户设置允许上传文件类型
            this.ControlMaxSize = Request.QueryString["MaxSize"];          //用户设置允许最大上传文件大小
            string ThumbWidth  = Request.QueryString["ThumbWidth"];
            string ThumbHeight = Request.QueryString["ThumbHeight"];
            string saveType    = Request.QueryString["SaveType"];

            if (Request.QueryString["IsMulti"] != "1")
            {
                IsMulti   = "false";
                divHeight = "60px";
            }
            if (uploadobj.IsEnableUpload != "1")  // 判断是否允许上传
            {
                Response.Write("已经关闭上传功能,请联系管理员");
                Response.End();
            }
            if (uploadobj.IsEnableWatermark == "1")
            {
                chkWater.Checked = true;
                if (uploadobj.WatermarkType == "0")
                {
                    WaterDivId.InnerHtml = "<br>水印文字为:<br><font color=red>" + uploadobj.WatermarkText + "</font>";
                }
                else
                {
                    if (System.IO.File.Exists(Server.MapPath("/" + uploadobj.WatermarkPic)))
                    {
                        WaterDivId.InnerHtml = "水印图片:<br><img src='/" + uploadobj.WatermarkPic + "' style='width:100px;border:1px solid #CCCCCC' alt='水印图片' title='水印图片'>";
                    }
                    else
                    {
                        WaterDivId.InnerHtml = "<font color=red>注,请上传水印图片,图片位置为:<br>/" + uploadobj.WatermarkPic + "</font>";
                    }
                }
            }

            txtWidth.Value  = string.IsNullOrEmpty(ThumbWidth) == true ? uploadobj.ThumbnailWidth : ThumbWidth;
            txtHeight.Value = string.IsNullOrEmpty(ThumbHeight) == true ? uploadobj.ThumbnailHeight : ThumbHeight;
            divID.Visible   = false;

            switch (this.UpType)
            {
            case "media":    //视频,flash
                MaxSize  = GetMaxSize(int.Parse(uploadobj.UploadMediaSize));
                AllowExt = GetExtType(uploadobj.UploadMediaType);
                break;

            case "file":    //文件
                MaxSize  = GetMaxSize(int.Parse(uploadobj.UploadFilesSize));
                AllowExt = GetExtType(uploadobj.UploadFilesType);
                break;

            case "image":    //图片
                MaxSize            = GetMaxSize(int.Parse(uploadobj.UploadImageSize));
                AllowExt           = GetExtType(uploadobj.UploadImageType);
                divID.Visible      = true;
                WaterDivId.Visible = true;
                break;

            default:
                break;
            }

            AllowExt = "*." + AllowExt.Replace("|", ";*.");
            string[]      extArr = AllowExt.Split(';'); //判断个数
            StringBuilder sb     = new StringBuilder("允许上传的文件类型:");
            if (extArr.Length > 5)
            {
                for (int i = 0; i < extArr.Length; i++)
                {
                    if (i % 9 == 0 && i != 0)
                    {
                        sb.Append("<br>");
                    }
                    if (i != 0)
                    {
                        sb.Append(";");
                    }
                    sb.Append(extArr[i]);
                }
            }
            else
            {
                sb.Append(AllowExt);
            }
            this.divAllowType.InnerHtml = sb.ToString();

            this.divAllowType.InnerHtml = this.divAllowType.InnerHtml + "<br>单个文件最大允许上传“" + Math.Round((decimal)MaxSize / 1048576, 2) + "M”";
            int bestWidth  = Utils.ParseInt(Request.QueryString["BestWidth"], 0);
            int bestHeight = Utils.ParseInt(Request.QueryString["BestHeight"], 0);
            if (this.UpType == "image" && (bestWidth > 0 || bestHeight > 0))
            {
                this.divAllowType.InnerHtml = this.divAllowType.InnerHtml + ";<br>图片最佳";
                if (bestWidth > 0)
                {
                    this.divAllowType.InnerHtml = this.divAllowType.InnerHtml + "宽度为:" + bestWidth + "px;";
                }
                if (bestHeight > 0)
                {
                    this.divAllowType.InnerHtml = this.divAllowType.InnerHtml + "高度为:" + bestHeight + "px";
                }
            }
            urlParam = "'ExtType':'" + this.ExtType + "','MaxSize':'" + MaxSize / 1024 + "','SiteDir':'" + SiteDir + "','UpType':'" + this.UpType + "','SaveType':'" + saveType + "'";
            #endregion

            #region  择文件
            // 操作处理
            CMSFileManage.FileManagerProcessor fileManage = new CMSFileManage.FileManagerProcessor(Request.QueryString["act"]);
            builder.Append(fileManage.Value);

            string upFileType  = this.UpType;
            string thisSiteDir = "/" + SiteDir;
            //文件不分站点保存
            thisSiteDir = "";
            switch (upFileType)
            {
            case "image":
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/images/");
                break;

            case "file":
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/files/");
                break;

            case "media":
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/medias/");
                break;

            default:
                RootUploadFiles = Server.MapPath("/uploadfiles" + thisSiteDir + "/files/");
                break;
            }

            if (string.IsNullOrEmpty(folderPath))
            {
                folderPath = RootUploadFiles;
            }
            else if (folderPath.IndexOf(":") == -1)
            {
                folderPath = Server.MapPath("/" + folderPath);
            }


            // 组合路径, 快速导航
            string comePath = "";
            foreach (string q in folderPath.Split('\\'))
            {
                comePath += q;
                currPath.AppendFormat("<a href=\"default.aspx?path={1}&pfile=" + Request.QueryString["pfile"] + "&FormName=" + Request.QueryString["FormName"] + "&ElementName=" + Request.QueryString["ElementName"] + "&ControlType=" + Request.QueryString["ControlType"] + "&UpType=" + Request.QueryString["UpType"] + "&ExtType=" + Request.QueryString["ExtType"] + "&MaxSize=" + Request.QueryString["MaxSize"] + "&GetSizeControl=" + Request.QueryString["GetSizeControl"] + "&ThumbWidth=" + Request.QueryString["ThumbWidth"] + "&ThumbHeight=" + Request.QueryString["ThumbHeight"] + "&BestWidth=" + Request.QueryString["BestWidth"] + "&BestHeight=" + Request.QueryString["BestHeight"] + "&IsMulti=" + Request.QueryString["IsMulti"] + "\">{0}</a>", q + "\\", comePath, upFileType);
                comePath += "\\";
            }

            // 返回上级
            //if (new DirectoryInfo(folderPath).Root.ToString().Replace("\\", "") != folderPath.ToUpper())
            if (RootUploadFiles.ToLower().IndexOf(folderPath.ToLower()) == -1)
            {
                string previousFolder = folderPath.Substring(0, folderPath.LastIndexOf("\\"));
                backHtml = "<a href=\"default.aspx?path=" + Server.UrlEncode(previousFolder) + "&pfile=" + Request.QueryString["pfile"] + "&FormName=" + Request.QueryString["FormName"] + "&ElementName=" + Request.QueryString["ElementName"] + "&ControlType=" + Request.QueryString["ControlType"] + "&UpType=" + Request.QueryString["UpType"] + "&ExtType=" + Request.QueryString["ExtType"] + "&MaxSize=" + Request.QueryString["MaxSize"] + "&GetSizeControl=" + Request.QueryString["GetSizeControl"] + "&ThumbWidth=" + Request.QueryString["ThumbWidth"] + "&ThumbHeight=" + Request.QueryString["ThumbHeight"] + "&BestWidth=" + Request.QueryString["BestWidth"] + "&BestHeight=" + Request.QueryString["BestHeight"] + "&IsMulti=" + Request.QueryString["IsMulti"] + "\"><img src=\"../../editor/ueditor/dialogs/video/folderback.gif\" alt=\"返回上级\" align=\"absmiddle\"  border=0/> 返回上级</a>";
            }
            else
            {
                folderPath += "\\";
            }
            folderPath = folderPath.Replace("\\\\", "\\");
            // 绑定数据
            fileManage = new CMSFileManage.FileManagerProcessor();
            List <CMSFileManage.FileFolderInfo> files = fileManage.GetDirectories(folderPath, "filesmanage.aspx");

            if (fileManage.Access)
            {
                BindData(files, fileManage);
            }
            else
            {
                builder.Append("无权限访问该目录. <a href='javascript:history.go(-1);' style='font-weight: normal'>后退</a>");
            }


            if (builder.ToString() != "")
            {
                string builderResult = builder.ToString();
                builder = new System.Text.StringBuilder("");
                builder.AppendFormat("<script type=\"text/javascript\">$(\"#tips\").show(); $(\"#tipsMsg\").html(\"{0}\"); </script>", builderResult.Replace(@"\", @"\\"));
            }
            #endregion
        }