Exemple #1
0
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <returns></returns>
        void UploadFile()
        {
            string fileName    = fuImage.FileName;
            string ext         = Path.GetExtension(fileName);
            string folder      = GetFileFolder();
            string newFileName = CreateFileName();

            string OrignPath    = folder.TrimEnd('/') + "/" + newFileName + ext;
            string physicalpath = Server.MapPath(folder);

            if (!Directory.Exists(physicalpath))
            {
                Directory.CreateDirectory(physicalpath);
            }
            string physicalfilepath = Server.MapPath(OrignPath);

            fuImage.SaveAs(physicalfilepath);

            imgCurrentImage.ImageUrl = OrignPath;

            ImageInfo info = new ImageInfo();

            info.Add(new ImageItem()
            {
                Size = "", Src = OrignPath, Type = ""
            });
            ImageValue.Value = info.ToJson();
        }
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <returns></returns>
        void UploadFile()
        {
            string fileName    = fuImage.FileName;
            string ext         = Path.GetExtension(fileName);
            string folder      = GetFileFolder();
            string newFileName = CreateFileName();

            OrignPath = folder.TrimEnd('/') + "/" + newFileName + ext;
            string physicalpath = Server.MapPath(folder);

            if (!Directory.Exists(physicalpath))
            {
                Directory.CreateDirectory(physicalpath);
            }
            string physicalfilepath = Server.MapPath(OrignPath);

            fuImage.SaveAs(physicalfilepath);

            ThumbPath = folder.TrimEnd('/') + "/" + newFileName + "_thumb" + ext;
            string physicaltargetpath = Server.MapPath(ThumbPath);

            CreateTumbnail(physicalfilepath, physicaltargetpath);
            imgThumb.ImageUrl = ThumbPath;


            info.Add(new ImageItem()
            {
                Size = "", Type = "", Src = OrignPath
            });
            ThumbnailConfig cfg = GetThumbnailCfg();

            if (cfg != null)
            {
                info.Add(new ImageItem()
                {
                    Size = cfg.Value, Type = cfg.Tag, Src = ThumbPath, Desc = cfg.Name
                });
            }
            ImageValue.Value = info.ToJson();
        }