Exemple #1
0
        protected void btnSaveImageData_Click(object sender, EventArgs e)
        {
            string str       = this.RePlaceImg.Value;
            int    photoId   = Convert.ToInt32(this.RePlaceId.Value);
            string photoPath = GalleryHelper.GetPhotoPath(photoId);
            string str3      = photoPath.Substring(photoPath.LastIndexOf("."));
            string extension = string.Empty;
            string str5      = string.Empty;

            try
            {
                HttpPostedFile postedFile = base.Request.Files[0];
                extension = Path.GetExtension(postedFile.FileName);
                if (str3 != extension)
                {
                    this.ShowMsgToTarget("上传图片类型与原文件类型不一致!", false, "parent");
                }
                else
                {
                    string str6 = Globals.GetStoragePath() + "/gallery";
                    str5 = photoPath.Substring(photoPath.LastIndexOf("/") + 1);
                    string str7        = str.Substring(str.LastIndexOf("/") - 6, 6);
                    string virtualPath = string.Empty;
                    if (str7.ToLower().Contains("weibo"))
                    {
                        virtualPath = Globals.GetStoragePath() + "/weibo/";
                    }
                    else
                    {
                        virtualPath = str6 + "/" + str7 + "/";
                    }
                    int           contentLength = postedFile.ContentLength;
                    string        path          = base.Request.MapPath(virtualPath);
                    string        text1         = str7 + "/" + str5;
                    DirectoryInfo info          = new DirectoryInfo(path);
                    if (!info.Exists)
                    {
                        info.Create();
                    }
                    if (!ResourcesHelper.CheckPostedFile(postedFile, "image"))
                    {
                        this.ShowMsgToTarget("文件上传的类型不正确!", false, "parent");
                    }
                    else if (contentLength >= 0x1f4000)
                    {
                        this.ShowMsgToTarget("图片文件已超过网站限制大小!", false, "parent");
                    }
                    else
                    {
                        postedFile.SaveAs(base.Request.MapPath(virtualPath + str5));
                        GalleryHelper.ReplacePhoto(photoId, contentLength);
                        this.CloseWindow();
                    }
                }
            }
            catch
            {
                this.ShowMsgToTarget("替换文件错误!", false, "parent");
            }
        }
        private void UploadImage(HttpContext context, HttpPostedFile file)
        {
            string str   = Globals.GetStoragePath() + "/" + this.uploadType;
            string str2  = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + Path.GetExtension(file.FileName);
            string str3  = str + "/images/" + str2;
            string str4  = str + "/thumbs40/40_" + str2;
            string str5  = str + "/thumbs60/60_" + str2;
            string str6  = str + "/thumbs100/100_" + str2;
            string str7  = str + "/thumbs160/160_" + str2;
            string str8  = str + "/thumbs180/180_" + str2;
            string str9  = str + "/thumbs220/220_" + str2;
            string str10 = str + "/thumbs310/310_" + str2;
            string str11 = str + "/thumbs410/410_" + str2;

            if (ResourcesHelper.CheckPostedFile(file, "image"))
            {
                file.SaveAs(context.Request.MapPath(Globals.ApplicationPath + str3));
                string sourceFilename = context.Request.MapPath(Globals.ApplicationPath + str3);
                ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str4), 40, 40);
                ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str5), 60, 60);
                ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str6), 100, 100);
                ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str7), 160, 160);
                ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str8), 180, 180);
                ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str9), 220, 220);
                ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str10), 310, 310);
                ResourcesHelper.CreateThumbnail(sourceFilename, context.Request.MapPath(Globals.ApplicationPath + str11), 410, 410);
                string[] strArray = new string[] { "'" + this.uploadType + "'", "'" + this.uploaderId + "'", "'" + str3 + "'", "'" + str4 + "'", "'" + str5 + "'", "'" + str6 + "'", "'" + str7 + "'", "'" + str8 + "'", "'" + str9 + "'", "'" + str10 + "'", "'" + str11 + "'" };
                context.Response.Write("<script type=\"text/javascript\">window.parent.UploadCallback(" + string.Join(",", strArray) + ");</script>");
            }
        }
Exemple #3
0
        protected void btnSaveImageData_Click(object sender, System.EventArgs e)
        {
            string value     = this.RePlaceImg.Value;
            int    photoId   = System.Convert.ToInt32(this.RePlaceId.Value);
            string photoPath = GalleryHelper.GetPhotoPath(photoId);
            string a         = photoPath.Substring(photoPath.LastIndexOf("."));
            string b         = string.Empty;
            string text      = string.Empty;

            try
            {
                System.Web.HttpFileCollection files          = base.Request.Files;
                System.Web.HttpPostedFile     httpPostedFile = files[0];
                b = System.IO.Path.GetExtension(httpPostedFile.FileName);
                if (a != b)
                {
                    this.ShowMsg("上传图片类型与原文件类型不一致!", false);
                }
                else
                {
                    string str = Globals.ApplicationPath + HiContext.Current.GetStoragePath() + "/gallery";
                    text = photoPath.Substring(photoPath.LastIndexOf("/") + 1);
                    string text2         = value.Substring(value.LastIndexOf("/") - 6, 6);
                    string text3         = str + "/" + text2 + "/";
                    int    contentLength = httpPostedFile.ContentLength;
                    string path          = base.Request.MapPath(text3);
                    //修改1
                    System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(path);
                    if (!directoryInfo.Exists)
                    {
                        directoryInfo.Create();
                    }
                    if (!ResourcesHelper.CheckPostedFile(httpPostedFile))
                    {
                        this.ShowMsg("文件上传的类型不正确!", false);
                    }
                    else
                    {
                        if (contentLength >= 2048000)
                        {
                            this.ShowMsg("图片文件已超过网站限制大小!", false);
                        }
                        else
                        {
                            httpPostedFile.SaveAs(base.Request.MapPath(text3 + text));
                            GalleryHelper.ReplacePhoto(photoId, contentLength);
                            this.CloseWindow();
                        }
                    }
                }
            }
            catch
            {
                this.ShowMsg("替换文件错误!", false);
            }
        }
 public static string UploadSKUImage(HttpPostedFile postedFile)
 {
     if (!ResourcesHelper.CheckPostedFile(postedFile, "image"))
     {
         return string.Empty;
     }
     string str = Globals.GetStoragePath() + "/sku/" + ResourcesHelper.GenerateFilename(Path.GetExtension(postedFile.FileName));
     postedFile.SaveAs(HttpContext.Current.Request.MapPath(Globals.ApplicationPath + str));
     return str;
 }
Exemple #5
0
        protected void btnSaveImageData_Click(object sender, System.EventArgs e)
        {
            string str       = this.RePlaceImg.Value;
            int    photoId   = System.Convert.ToInt32(this.RePlaceId.Value);
            string photoPath = GalleryHelper.GetPhotoPath(photoId);
            string str2      = photoPath.Substring(photoPath.LastIndexOf("."));
            string extension = string.Empty;
            string str3      = string.Empty;

            try
            {
                System.Web.HttpPostedFile postedFile = base.Request.Files[0];
                extension = System.IO.Path.GetExtension(postedFile.FileName);
                if (str2 != extension)
                {
                    this.ShowMsg("上传图片类型与原文件类型不一致!", false);
                }
                else
                {
                    string str4 = Globals.GetStoragePath() + "/gallery";
                    str3 = photoPath.Substring(photoPath.LastIndexOf("/") + 1);
                    string str5                  = str.Substring(str.LastIndexOf("/") - 6, 6);
                    string virtualPath           = str4 + "/" + str5 + "/";
                    int    contentLength         = postedFile.ContentLength;
                    string path                  = base.Request.MapPath(virtualPath);
                    string text                  = str5 + "/" + str3;
                    System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(path);
                    if (!info.Exists)
                    {
                        info.Create();
                    }
                    if (!ResourcesHelper.CheckPostedFile(postedFile))
                    {
                        this.ShowMsg("文件上传的类型不正确!", false);
                    }
                    else
                    {
                        if (contentLength >= 2048000)
                        {
                            this.ShowMsg("图片文件已超过网站限制大小!", false);
                        }
                        else
                        {
                            postedFile.SaveAs(base.Request.MapPath(virtualPath + str3));
                            GalleryHelper.ReplacePhoto(photoId, contentLength);
                            this.CloseWindow();
                        }
                    }
                }
            }
            catch
            {
                this.ShowMsg("替换文件错误!", false);
            }
        }
        private string UploadSubjectImg(HttpPostedFile postedFile)
        {
            if (!ResourcesHelper.CheckPostedFile(postedFile))
            {
                return(string.Empty);
            }
            string virtualPath = Globals.ApplicationPath + string.Format("/Templates/sites/{0}/{1}/productsubject/{2}", HiContext.Current.User.UserId, themName, ResourcesHelper.GenerateFilename(Path.GetExtension(postedFile.FileName)));

            postedFile.SaveAs(HttpContext.Current.Request.MapPath(virtualPath));
            return(virtualPath);
        }
        public static string UploadSKUImage(HttpPostedFile postedFile)
        {
            if (!ResourcesHelper.CheckPostedFile(postedFile, "image", null))
            {
                return(string.Empty);
            }
            string text = HiContext.Current.GetStoragePath() + "/sku/" + ResourcesHelper.GenerateFilename(Path.GetExtension(postedFile.FileName));

            postedFile.SaveAs(HiContext.Current.Context.Request.MapPath(text));
            return(text);
        }
Exemple #8
0
        public static string UploadDefautBg(HttpPostedFile postedFile)
        {
            if (!ResourcesHelper.CheckPostedFile(postedFile, "image"))
            {
                return(string.Empty);
            }
            string str = Globals.GetVshopSkinPath(null) + "/images/ad/DefautPageBg" + Path.GetExtension(postedFile.FileName);

            postedFile.SaveAs(HttpContext.Current.Request.MapPath(Globals.ApplicationPath + str));
            return(str);
        }
Exemple #9
0
        public static string UploadWeiXinCodeImage(HttpPostedFile postedFile)
        {
            if (!ResourcesHelper.CheckPostedFile(postedFile, "image"))
            {
                return(string.Empty);
            }
            string str = Globals.GetStoragePath() + "/WeiXinCodeImageUrl" + Path.GetExtension(postedFile.FileName);

            postedFile.SaveAs(HttpContext.Current.Request.MapPath(Globals.ApplicationPath + str));
            return(str);
        }
Exemple #10
0
        private void btnSaveImageFtp_Click(object sender, EventArgs e)
        {
            string str        = Globals.GetStoragePath() + "/gallery";
            int    categoryId = Convert.ToInt32(this.dropImageFtp.SelectedItem.Value);
            int    num2       = 0;
            int    num3       = 0;

            new StringBuilder();
            HttpFileCollection files = base.Request.Files;

            for (int i = 0; i < files.Count; i++)
            {
                HttpPostedFile postedFile = files[i];
                if (postedFile.ContentLength > 0)
                {
                    num2++;
                    try
                    {
                        string        str2          = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture) + Path.GetExtension(postedFile.FileName);
                        string        str3          = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf(@"\") + 1);
                        string        photoName     = str3.Substring(0, str3.LastIndexOf("."));
                        string        str5          = DateTime.Now.ToString("yyyyMM").Substring(0, 6);
                        string        virtualPath   = str + "/" + str5 + "/";
                        int           contentLength = postedFile.ContentLength;
                        string        path          = base.Request.MapPath(virtualPath);
                        string        photoPath     = "/Storage/master/gallery/" + str5 + "/" + str2;
                        DirectoryInfo info          = new DirectoryInfo(path);
                        if (ResourcesHelper.CheckPostedFile(postedFile, "image"))
                        {
                            if (!info.Exists)
                            {
                                info.Create();
                            }
                            postedFile.SaveAs(base.Request.MapPath(virtualPath + str2));
                            if (GalleryHelper.AddPhote(categoryId, photoName, photoPath, contentLength))
                            {
                                num3++;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            if (num2 == 0)
            {
                this.ShowMsg("至少需要选择一个图片文件!", false);
            }
            else
            {
                this.ShowMsg("成功上传了" + num3.ToString() + "个文件!", true);
            }
        }
        public static string UploadLogo(HttpPostedFile postedFile)
        {
            if (!ResourcesHelper.CheckPostedFile(postedFile))
            {
                return(string.Empty);
            }
            string str = HiContext.Current.GetStoragePath() + "/" + ResourcesHelper.GenerateFilename(Path.GetExtension(postedFile.FileName));

            postedFile.SaveAs(HiContext.Current.Context.Request.MapPath(Globals.ApplicationPath + str));
            return(str);
        }
        protected void btnSaveImageData_Click(object sender, EventArgs e)
        {
            string value     = this.RePlaceImg.Value;
            int    photoId   = Convert.ToInt32(this.RePlaceId.Value);
            string photoPath = GalleryHelper.GetPhotoPath(photoId);
            string a         = photoPath.Substring(photoPath.LastIndexOf("."));
            string empty     = string.Empty;
            string empty2    = string.Empty;

            try
            {
                HttpFileCollection files          = base.Request.Files;
                HttpPostedFile     httpPostedFile = files[0];
                empty = Path.GetExtension(httpPostedFile.FileName);
                if (a != empty)
                {
                    this.ShowMsg("上传图片类型与原文件类型不一致!", false);
                }
                else
                {
                    string str = HiContext.Current.GetStoragePath() + "/gallery";
                    empty2 = photoPath.Substring(photoPath.LastIndexOf("/") + 1);
                    string        text          = value.Substring(value.LastIndexOf("/") - 6, 6);
                    string        text2         = str + "/" + text + "/";
                    int           contentLength = httpPostedFile.ContentLength;
                    string        path          = base.Request.MapPath(text2);
                    string        text3         = text + "/" + empty2;
                    DirectoryInfo directoryInfo = new DirectoryInfo(path);
                    if (!directoryInfo.Exists)
                    {
                        directoryInfo.Create();
                    }
                    if (!ResourcesHelper.CheckPostedFile(httpPostedFile, "image", null))
                    {
                        this.ShowMsg("文件上传的类型不正确!", false);
                    }
                    else if (contentLength >= 2048000)
                    {
                        this.ShowMsg("图片文件已超过网站限制大小!", false);
                    }
                    else
                    {
                        httpPostedFile.SaveAs(base.Request.MapPath(text2 + empty2));
                        GalleryHelper.ReplacePhoto(photoId, contentLength);
                        this.CloseWindow();
                    }
                }
            }
            catch
            {
                this.ShowMsg("替换文件错误!", false);
            }
        }
Exemple #13
0
        private void btnSaveImageFtp_Click(object sender, System.EventArgs e)
        {
            string str        = Globals.ApplicationPath + Hidistro.Membership.Context.HiContext.Current.GetStoragePath() + "/gallery";
            int    categoryId = System.Convert.ToInt32(this.dropImageFtp.SelectedItem.Value);
            int    num        = 0;
            int    num2       = 0;

            new System.Text.StringBuilder();
            System.Web.HttpFileCollection files = base.Request.Files;
            for (int i = 0; i < files.Count; i++)
            {
                System.Web.HttpPostedFile httpPostedFile = files[i];
                if (httpPostedFile.ContentLength > 0)
                {
                    num++;
                    try
                    {
                        string text          = System.Guid.NewGuid().ToString("N", System.Globalization.CultureInfo.InvariantCulture) + System.IO.Path.GetExtension(httpPostedFile.FileName);
                        string text2         = httpPostedFile.FileName.Substring(httpPostedFile.FileName.LastIndexOf("\\") + 1);
                        string photoName     = text2.Substring(0, text2.LastIndexOf("."));
                        string text3         = System.DateTime.Now.ToString("yyyyMM").Substring(0, 6);
                        string text4         = str + "/" + text3 + "/";
                        int    contentLength = httpPostedFile.ContentLength;
                        string path          = base.Request.MapPath(text4);
                        string photoPath     = "/Storage/master/gallery/" + text3 + "/" + text;
                        System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(path);
                        if (ResourcesHelper.CheckPostedFile(httpPostedFile))
                        {
                            if (!directoryInfo.Exists)
                            {
                                directoryInfo.Create();
                            }
                            httpPostedFile.SaveAs(base.Request.MapPath(text4 + text));
                            if (GalleryHelper.AddPhote(categoryId, photoName, photoPath, contentLength))
                            {
                                num2++;
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            if (num == 0)
            {
                this.ShowMsg("至少需要选择一个图片文件!", false);
                return;
            }
            this.ShowMsg("成功上传了" + num2.ToString() + "个文件!", true);
        }
Exemple #14
0
        private void btnSaveImageData_Click(object sender, EventArgs e)
        {
            string str       = RePlaceImg.Value;
            int    photoId   = Convert.ToInt32(RePlaceId.Value);
            string photoPath = GalleryHelper.GetPhotoPath(photoId);
            string str3      = photoPath.Substring(photoPath.LastIndexOf("."));
            string extension = string.Empty;
            string str5      = string.Empty;

            try
            {
                HttpPostedFile postedFile = base.Request.Files[0];
                extension = Path.GetExtension(postedFile.FileName);
                if (str3 != extension)
                {
                    ShowMsg("上传图片类型与原文件类型不一致!", false);
                    return;
                }
                string str6 = Globals.ApplicationPath + HiContext.Current.GetStoragePath() + "/gallery";
                str5 = photoPath.Substring(photoPath.LastIndexOf("/") + 1);
                string        str7          = str.Substring(str.LastIndexOf("/") - 6, 6);
                string        virtualPath   = str6 + "/" + str7 + "/";
                int           contentLength = postedFile.ContentLength;
                string        path          = base.Request.MapPath(virtualPath);
                string        str10         = str7 + "/" + str5;
                DirectoryInfo info          = new DirectoryInfo(path);
                if (!info.Exists)
                {
                    info.Create();
                }
                if (!ResourcesHelper.CheckPostedFile(postedFile))
                {
                    ShowMsg("文件上传的类型不正确!", false);
                    return;
                }
                if (contentLength >= 0x1f4000)
                {
                    ShowMsg("图片文件已超过网站限制大小!", false);
                    return;
                }
                postedFile.SaveAs(base.Request.MapPath(virtualPath + str5));
                GalleryHelper.ReplacePhoto(photoId, contentLength);
            }
            catch
            {
                ShowMsg("替换文件错误!", false);
                return;
            }
            BindImageData();
        }
Exemple #15
0
		public static string UploadLogo(HttpPostedFile postedFile)
		{
			string result;
			if (!ResourcesHelper.CheckPostedFile(postedFile))
			{
				result = string.Empty;
			}
			else
			{
				string text = HiContext.Current.GetStoragePath() + ResourcesHelper.GenerateFilename(Path.GetExtension(postedFile.FileName));
				postedFile.SaveAs(HiContext.Current.Context.Request.MapPath(Globals.ApplicationPath + text));
				result = text;
			}
			return result;
		}
Exemple #16
0
        public static string UploadVipQRImage(HttpPostedFile postedFile)
        {
            string result;

            if (!ResourcesHelper.CheckPostedFile(postedFile, "image"))
            {
                result = string.Empty;
            }
            else
            {
                string text = Globals.GetStoragePath() + "/Vipcard/vipqr" + Path.GetExtension(postedFile.FileName);
                postedFile.SaveAs(HttpContext.Current.Request.MapPath(Globals.ApplicationPath + text));
                result = text;
            }
            return(result);
        }
Exemple #17
0
        public static string UploadBrandCategorieImage(HttpPostedFile postedFile)
        {
            string result;

            if (!ResourcesHelper.CheckPostedFile(postedFile, "image"))
            {
                result = string.Empty;
            }
            else
            {
                string text = Globals.GetStoragePath() + "/brand/" + ResourcesHelper.GenerateFilename(Path.GetExtension(postedFile.FileName));
                postedFile.SaveAs(HttpContext.Current.Request.MapPath(Globals.ApplicationPath + text));
                result = text;
            }
            return(result);
        }
Exemple #18
0
        public static string UploadDefautBg(HttpPostedFile postedFile)
        {
            string result;

            if (!ResourcesHelper.CheckPostedFile(postedFile, "image"))
            {
                result = string.Empty;
            }
            else
            {
                string text = Globals.GetVshopSkinPath(null) + "/images/ad/DefautPageBg" + Path.GetExtension(postedFile.FileName);
                postedFile.SaveAs(HttpContext.Current.Request.MapPath(Globals.ApplicationPath + text));
                result = text;
            }
            return(result);
        }
Exemple #19
0
        public static string UploadWeiXinCodeImage(HttpPostedFile postedFile)
        {
            string result;

            if (!ResourcesHelper.CheckPostedFile(postedFile))
            {
                result = string.Empty;
            }
            else
            {
                string text = HiContext.Current.GetStoragePath() + "/WeiXinCodeImageUrl" + Path.GetExtension(postedFile.FileName);
                postedFile.SaveAs(HttpContext.Current.Request.MapPath(Globals.ApplicationPath + text));
                result = text;
            }
            return(result);
        }
Exemple #20
0
        public static string UploadSKUImage(HttpPostedFile postedFile)
        {
            string empty;

            if (ResourcesHelper.CheckPostedFile(postedFile, "image"))
            {
                string str = string.Concat(Globals.GetStoragePath(), "/sku/", ResourcesHelper.GenerateFilename(Path.GetExtension(postedFile.FileName)));
                Globals.UploadFileAndCheck(postedFile, HttpContext.Current.Request.MapPath(string.Concat(Globals.ApplicationPath, str)));
                empty = str;
            }
            else
            {
                empty = string.Empty;
            }
            return(empty);
        }
Exemple #21
0
        public static string UploadImportSourceTypeIcon(HttpPostedFile postedFile)
        {
            string result;

            if (!ResourcesHelper.CheckPostedFile(postedFile))
            {
                result = string.Empty;
            }
            else
            {
                if (!Directory.Exists(HiContext.Current.Context.Request.MapPath(Globals.ApplicationPath + HiContext.Current.GetStoragePath() + "/ImportSourceType/")))
                {
                    Directory.CreateDirectory(HiContext.Current.Context.Request.MapPath(Globals.ApplicationPath + HiContext.Current.GetStoragePath() + "/ImportSourceType/"));
                }
                string text = HiContext.Current.GetStoragePath() + "/ImportSourceType/" + ResourcesHelper.GenerateFilename(Path.GetExtension(postedFile.FileName));
                postedFile.SaveAs(HiContext.Current.Context.Request.MapPath(Globals.ApplicationPath + text));
                result = text;
            }
            return(result);
        }
Exemple #22
0
        /// <summary>
        ///限时抢购获取上传地址
        /// </summary>
        /// <param name="postedFile"></param>
        /// <returns></returns>
        public static string UploadActiveCategorieImage(HttpPostedFile postedFile)
        {
            string result;

            if (!ResourcesHelper.CheckPostedFile(postedFile))
            {
                result = string.Empty;
            }
            else
            {
                if (Directory.Exists(System.Web.HttpContext.Current.Server.MapPath(HiContext.Current.GetStoragePath() + "/ActiveCategorie")) == false)
                {
                    Directory.CreateDirectory(System.Web.HttpContext.Current.Server.MapPath(HiContext.Current.GetStoragePath() + "/ActiveCategorie"));
                }
                string text = HiContext.Current.GetStoragePath() + "/ActiveCategorie/" + ResourcesHelper.GenerateFilename(Path.GetExtension(postedFile.FileName));
                postedFile.SaveAs(HiContext.Current.Context.Request.MapPath(Globals.ApplicationPath + text));
                result = text;
            }
            return(result);
        }
Exemple #23
0
 private bool CheckUploadFile(System.Web.HttpPostedFile imgFile, ref string dirPath)
 {
     if (imgFile == null)
     {
         this.showError("请选择上传文件");
         return(false);
     }
     if (!ResourcesHelper.CheckPostedFile(imgFile))
     {
         this.showError("不能上传空文件,且必须是有效的图片文件!");
         return(false);
     }
     dirPath = Globals.MapPath(this.savePath);
     if (!System.IO.Directory.Exists(dirPath))
     {
         this.showError("上传目录不存在。");
         return(false);
     }
     return(true);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpFileCollection files = base.Request.Files;

            if (files.Count > 0)
            {
                string         str        = HttpContext.Current.Request.MapPath(Globals.ApplicationPath + "/Storage/master/flex");
                HttpPostedFile postedFile = files[0];
                string         str2       = Path.GetExtension(postedFile.FileName).ToLower();
                if ((((str2 != ".jpg") && (str2 != ".gif")) && ((str2 != ".jpeg") && (str2 != ".png"))) && (str2 != ".bmp"))
                {
                    base.Response.Write("1");
                }
                else
                {
                    string s        = DateTime.Now.ToString("yyyyMMdd") + new Random().Next(0x2710, 0x1869f).ToString(CultureInfo.InvariantCulture) + str2;
                    string filename = str + "/" + s;
                    try
                    {
                        if (!ResourcesHelper.CheckPostedFile(postedFile, "image"))
                        {
                            base.Response.Write("0");
                        }
                        else
                        {
                            postedFile.SaveAs(filename);
                            base.Response.Write(s);
                        }
                    }
                    catch
                    {
                        base.Response.Write("0");
                    }
                }
            }
            else
            {
                base.Response.Write("2");
            }
        }
Exemple #25
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     System.Web.HttpFileCollection files = base.Request.Files;
     if (files.Count > 0)
     {
         string str = System.Web.HttpContext.Current.Request.MapPath(Globals.ApplicationPath + "/Storage/master/flex");
         System.Web.HttpPostedFile httpPostedFile = files[0];
         string text = System.IO.Path.GetExtension(httpPostedFile.FileName).ToLower();
         if (text != ".jpg" && text != ".gif" && text != ".jpeg" && text != ".png" && text != ".bmp")
         {
             base.Response.Write("1");
             return;
         }
         string text2 = System.DateTime.Now.ToString("yyyyMMdd") + new System.Random().Next(10000, 99999).ToString(System.Globalization.CultureInfo.InvariantCulture);
         text2 += text;
         string filename = str + "/" + text2;
         try
         {
             if (!ResourcesHelper.CheckPostedFile(httpPostedFile, "image"))
             {
                 base.Response.Write("0");
             }
             else
             {
                 httpPostedFile.SaveAs(filename);
                 base.Response.Write(text2);
             }
             return;
         }
         catch
         {
             base.Response.Write("0");
             return;
         }
     }
     base.Response.Write("2");
 }
Exemple #26
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(0, Hidistro.Membership.Context.Users.GetLoggedOnUsername(), true, true);
            if (user.UserRole != Hidistro.Membership.Core.Enums.UserRole.Distributor && user.UserRole != Hidistro.Membership.Core.Enums.UserRole.SiteManager)
            {
                this.showError("您没有权限执行此操作!");
                return;
            }
            string a = "false";

            if (base.Request.Form["isAdvPositions"] != null)
            {
                a = base.Request.Form["isAdvPositions"].ToString().ToLower().Trim();
            }
            if (user.UserRole == Hidistro.Membership.Core.Enums.UserRole.SiteManager)
            {
                if (a == "false")
                {
                    this.savePath = "~/Storage/master/gallery/";
                    this.saveUrl  = "/Storage/master/gallery/";
                }
                else
                {
                    this.savePath = string.Format("{0}/fckfiles/Files/Image/", Hidistro.Membership.Context.HiContext.Current.GetSkinPath());
                    if (base.Request.ApplicationPath != "/")
                    {
                        this.saveUrl = this.savePath.Substring(base.Request.ApplicationPath.Length);
                    }
                    else
                    {
                        this.saveUrl = this.savePath;
                    }
                }
            }
            else
            {
                if (a == "false")
                {
                    this.savePath = string.Format("~/Storage/sites/{0}/fckfiles/", user.UserId);
                    this.saveUrl  = string.Format("/Storage/sites/{0}/fckfiles/", user.UserId);
                }
                else
                {
                    Hidistro.Membership.Context.SiteSettings siteSettings = Hidistro.Membership.Context.SettingsManager.GetSiteSettings(user.UserId);
                    this.savePath = string.Format("~/Templates/sites/{0}/{1}/fckfiles/Files/Image/", user.UserId, siteSettings.Theme);
                    this.saveUrl  = string.Format("/Templates/sites/{0}/{1}/fckfiles/Files/Image/", user.UserId, siteSettings.Theme);
                }
            }
            int num = 0;

            if (base.Request.Form["fileCategory"] != null)
            {
                int.TryParse(base.Request.Form["fileCategory"], out num);
            }
            string text = string.Empty;

            if (base.Request.Form["imgTitle"] != null)
            {
                text = base.Request.Form["imgTitle"];
            }
            System.Web.HttpPostedFile httpPostedFile = base.Request.Files["imgFile"];
            if (httpPostedFile == null)
            {
                this.showError("请先选择文件!");
            }
            if (!ResourcesHelper.CheckPostedFile(httpPostedFile))
            {
                this.showError("不能上传空文件,且必须是有效的图片文件!");
                return;
            }
            string text2 = base.Server.MapPath(this.savePath);

            if (!System.IO.Directory.Exists(text2))
            {
                this.showError("上传目录不存在。");
            }
            if (a == "false" && user.UserRole == Hidistro.Membership.Core.Enums.UserRole.SiteManager)
            {
                text2        += string.Format("{0}/", System.DateTime.Now.ToString("yyyyMM"));
                this.saveUrl += string.Format("{0}/", System.DateTime.Now.ToString("yyyyMM"));
            }
            if (!System.IO.Directory.Exists(text2))
            {
                System.IO.Directory.CreateDirectory(text2);
            }
            string fileName = httpPostedFile.FileName;

            if (text.Length == 0)
            {
                text = fileName;
            }
            string str      = System.IO.Path.GetExtension(fileName).ToLower();
            string str2     = System.DateTime.Now.ToString("yyyyMMddHHmmss_ffff", System.Globalization.DateTimeFormatInfo.InvariantInfo) + str;
            string filename = text2 + str2;
            string text3    = this.saveUrl + str2;

            try
            {
                httpPostedFile.SaveAs(filename);
                if (user.UserRole == Hidistro.Membership.Core.Enums.UserRole.SiteManager && a == "false")
                {
                    Database database = DatabaseFactory.CreateDatabase();
                    System.Data.Common.DbCommand sqlStringCommand = database.GetSqlStringCommand("insert into Hishop_PhotoGallery(CategoryId,PhotoName,PhotoPath,FileSize,UploadTime,LastUpdateTime)values(@cid,@name,@path,@size,@time,@time1)");
                    database.AddInParameter(sqlStringCommand, "cid", System.Data.DbType.Int32, num);
                    database.AddInParameter(sqlStringCommand, "name", System.Data.DbType.String, text);
                    database.AddInParameter(sqlStringCommand, "path", System.Data.DbType.String, text3);
                    database.AddInParameter(sqlStringCommand, "size", System.Data.DbType.Int32, httpPostedFile.ContentLength);
                    database.AddInParameter(sqlStringCommand, "time", System.Data.DbType.DateTime, System.DateTime.Now);
                    database.AddInParameter(sqlStringCommand, "time1", System.Data.DbType.DateTime, System.DateTime.Now);
                    database.ExecuteNonQuery(sqlStringCommand);
                }
            }
            catch
            {
                this.showError("保存文件出错!");
            }
            System.Collections.Hashtable hashtable = new System.Collections.Hashtable();
            hashtable["error"] = 0;
            hashtable["url"]   = Globals.ApplicationPath + text3;
            base.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            base.Response.Write(JsonMapper.ToJson(hashtable));
            base.Response.End();
        }
Exemple #27
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (ManagerHelper.GetCurrentManager() == null)
            {
                this.showError("您没有权限执行此操作!");
            }
            else
            {
                this.savePath = "~/Storage/master/gallery/";

                this.saveUrl = "/Storage/master/gallery/";

                int cid = 0;

                if (Request.Form["fileCategory"] != null)
                {
                    int.TryParse(base.Request.Form["fileCategory"], out cid);
                }

                string name = string.Empty;

                if (Request.Form["imgTitle"] != null)
                {
                    name = base.Request.Form["imgTitle"];
                }


                System.Web.HttpPostedFile postedFile = Request.Files["imgFile"];

                if (postedFile == null)
                {
                    this.showError("请先选择文件!");
                }
                else
                {
                    if (!ResourcesHelper.CheckPostedFile(postedFile))
                    {
                        this.showError("不能上传空文件,且必须是有效的图片文件!");
                    }
                    else
                    {
                        string path = Server.MapPath(this.savePath);

                        if (!System.IO.Directory.Exists(path))
                        {
                            this.showError("上传目录不存在。");
                        }
                        else
                        {
                            path += string.Format("{0}/", System.DateTime.Now.ToString("yyyyMM"));

                            this.saveUrl += string.Format("{0}/", System.DateTime.Now.ToString("yyyyMM"));

                            if (!System.IO.Directory.Exists(path))
                            {
                                System.IO.Directory.CreateDirectory(path);
                            }

                            string fileName = postedFile.FileName;

                            if (name.Length == 0)
                            {
                                name = fileName;
                            }

                            ///取出文件扩展名
                            string fileExt = System.IO.Path.GetExtension(fileName).ToLower();

                            //生成新的文件名
                            string newFileName = System.DateTime.Now.ToString("yyyyMMddHHmmss_ffff", System.Globalization.DateTimeFormatInfo.InvariantInfo) + fileExt;

                            //文件保存真实路径
                            string filename = path + newFileName;

                            //网站相对路径
                            string relativePath = this.saveUrl + newFileName;

                            bool err = false;

                            try
                            {
                                postedFile.SaveAs(filename);

                                Database database = DatabaseFactory.CreateDatabase();
                                System.Data.Common.DbCommand sqlStringCommand = database.GetSqlStringCommand("insert into Hishop_PhotoGallery(CategoryId,PhotoName,PhotoPath,FileSize,UploadTime,LastUpdateTime)values(@cid,@name,@path,@size,@time,@time1)");
                                database.AddInParameter(sqlStringCommand, "cid", System.Data.DbType.Int32, cid);
                                database.AddInParameter(sqlStringCommand, "name", System.Data.DbType.String, name);
                                database.AddInParameter(sqlStringCommand, "path", System.Data.DbType.String, relativePath);
                                database.AddInParameter(sqlStringCommand, "size", System.Data.DbType.Int32, postedFile.ContentLength);
                                database.AddInParameter(sqlStringCommand, "time", System.Data.DbType.DateTime, System.DateTime.Now);
                                database.AddInParameter(sqlStringCommand, "time1", System.Data.DbType.DateTime, System.DateTime.Now);
                                database.ExecuteNonQuery(sqlStringCommand);
                            }
                            catch
                            {
                                err = true;
                                this.showError("保存文件出错!");
                            }
                            finally { }

                            if (!err)
                            {
                                System.Collections.Hashtable hashtable = new System.Collections.Hashtable();
                                hashtable["error"] = 0;
                                hashtable["url"]   = Globals.ApplicationPath + relativePath;
                                Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                                Response.Write(JsonMapper.ToJson(hashtable));
                                Response.End();
                            }
                        }
                    }
                }
            }
        }
Exemple #28
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (ManagerHelper.GetCurrentManager() == null)
            {
                this.showError("您没有权限执行此操作!");
                return;
            }
            this.savePath = "~/Storage/master/gallery/";
            this.saveUrl  = "/Storage/master/gallery/";
            int num = 0;

            if (base.Request.Form["fileCategory"] != null)
            {
                int.TryParse(base.Request.Form["fileCategory"], out num);
            }
            string text = string.Empty;

            if (base.Request.Form["imgTitle"] != null)
            {
                text = base.Request.Form["imgTitle"];
            }
            System.Web.HttpPostedFile httpPostedFile = base.Request.Files["imgFile"];
            if (httpPostedFile == null)
            {
                this.showError("请先选择文件!");
                return;
            }
            if (!ResourcesHelper.CheckPostedFile(httpPostedFile, "image"))
            {
                this.showError("不能上传空文件,且必须是有效的图片文件!");
                return;
            }
            string text2 = base.Server.MapPath(this.savePath);

            if (!System.IO.Directory.Exists(text2))
            {
                this.showError("上传目录不存在。");
                return;
            }
            text2        += string.Format("{0}/", System.DateTime.Now.ToString("yyyyMM"));
            this.saveUrl += string.Format("{0}/", System.DateTime.Now.ToString("yyyyMM"));
            if (!System.IO.Directory.Exists(text2))
            {
                System.IO.Directory.CreateDirectory(text2);
            }
            string fileName = httpPostedFile.FileName;

            if (text.Length == 0)
            {
                text = fileName;
            }
            string str      = System.IO.Path.GetExtension(fileName).ToLower();
            string str2     = System.DateTime.Now.ToString("yyyyMMddHHmmss_ffff", System.Globalization.DateTimeFormatInfo.InvariantInfo) + str;
            string filename = text2 + str2;
            string text3    = this.saveUrl + str2;

            try
            {
                httpPostedFile.SaveAs(filename);
                Database database = DatabaseFactory.CreateDatabase();
                System.Data.Common.DbCommand sqlStringCommand = database.GetSqlStringCommand("insert into Hishop_PhotoGallery(CategoryId,PhotoName,PhotoPath,FileSize,UploadTime,LastUpdateTime)values(@cid,@name,@path,@size,@time,@time1)");
                database.AddInParameter(sqlStringCommand, "cid", System.Data.DbType.Int32, num);
                database.AddInParameter(sqlStringCommand, "name", System.Data.DbType.String, text);
                database.AddInParameter(sqlStringCommand, "path", System.Data.DbType.String, text3);
                database.AddInParameter(sqlStringCommand, "size", System.Data.DbType.Int32, httpPostedFile.ContentLength);
                database.AddInParameter(sqlStringCommand, "time", System.Data.DbType.DateTime, System.DateTime.Now);
                database.AddInParameter(sqlStringCommand, "time1", System.Data.DbType.DateTime, System.DateTime.Now);
                database.ExecuteNonQuery(sqlStringCommand);
            }
            catch
            {
                this.showError("保存文件出错!");
            }
            System.Collections.Hashtable hashtable = new System.Collections.Hashtable();
            hashtable["error"] = 0;
            hashtable["url"]   = Globals.ApplicationPath + text3;
            base.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
            base.Response.Write(JsonMapper.ToJson(hashtable));
            base.Response.End();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IUser user = Users.GetUser(0, Users.GetLoggedOnUsername(), true, true);

            if ((user.UserRole != UserRole.Distributor) && (user.UserRole != UserRole.SiteManager))
            {
                this.showError("您没有权限执行此操作!");
            }
            else
            {
                string str = "false";
                if (base.Request.Form["isAdvPositions"] != null)
                {
                    str = base.Request.Form["isAdvPositions"].ToString().ToLower().Trim();
                }
                if (user.UserRole == UserRole.SiteManager)
                {
                    if (str == "false")
                    {
                        this.savePath = "~/Storage/master/gallery/";
                        this.saveUrl  = "/Storage/master/gallery/";
                    }
                    else
                    {
                        this.savePath = string.Format("{0}/fckfiles/Files/Image/", HiContext.Current.GetSkinPath());
                        if (base.Request.ApplicationPath != "/")
                        {
                            this.saveUrl = this.savePath.Substring(base.Request.ApplicationPath.Length);
                        }
                        else
                        {
                            this.saveUrl = this.savePath;
                        }
                    }
                }
                else if (str == "false")
                {
                    this.savePath = string.Format("~/Storage/sites/{0}/fckfiles/", user.UserId);
                    this.saveUrl  = string.Format("/Storage/sites/{0}/fckfiles/", user.UserId);
                }
                else
                {
                    SiteSettings siteSettings = SettingsManager.GetSiteSettings(user.UserId);
                    this.savePath = string.Format("~/Templates/sites/{0}/{1}/fckfiles/Files/Image/", user.UserId, siteSettings.Theme);
                    this.saveUrl  = string.Format("/Templates/sites/{0}/{1}/fckfiles/Files/Image/", user.UserId, siteSettings.Theme);
                }
                int result = 0;
                if (base.Request.Form["fileCategory"] != null)
                {
                    int.TryParse(base.Request.Form["fileCategory"], out result);
                }
                string str2 = string.Empty;
                if (base.Request.Form["imgTitle"] != null)
                {
                    str2 = base.Request.Form["imgTitle"];
                }
                HttpPostedFile postedFile = base.Request.Files["imgFile"];
                if (postedFile == null)
                {
                    this.showError("请先选择文件!");
                }
                if (!ResourcesHelper.CheckPostedFile(postedFile))
                {
                    this.showError("不能上传空文件,且必须是有效的图片文件!");
                }
                else
                {
                    string path = base.Server.MapPath(this.savePath);
                    if (!Directory.Exists(path))
                    {
                        this.showError("上传目录不存在。");
                    }
                    if ((str == "false") && (user.UserRole == UserRole.SiteManager))
                    {
                        path         = path + string.Format("{0}/", DateTime.Now.ToString("yyyyMM"));
                        this.saveUrl = this.saveUrl + string.Format("{0}/", DateTime.Now.ToString("yyyyMM"));
                    }
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    string fileName = postedFile.FileName;
                    if (str2.Length == 0)
                    {
                        str2 = fileName;
                    }
                    string str5     = Path.GetExtension(fileName).ToLower();
                    string str6     = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + str5;
                    string filename = path + str6;
                    string str8     = this.saveUrl + str6;
                    try
                    {
                        postedFile.SaveAs(filename);
                        if ((user.UserRole == UserRole.SiteManager) && (str == "false"))
                        {
                            Database  database         = DatabaseFactory.CreateDatabase();
                            DbCommand sqlStringCommand = database.GetSqlStringCommand("insert into Hishop_PhotoGallery(CategoryId,PhotoName,PhotoPath,FileSize,UploadTime,LastUpdateTime)values(@cid,@name,@path,@size,@time,@time1)");
                            database.AddInParameter(sqlStringCommand, "cid", DbType.Int32, result);
                            database.AddInParameter(sqlStringCommand, "name", DbType.String, str2);
                            database.AddInParameter(sqlStringCommand, "path", DbType.String, str8);
                            database.AddInParameter(sqlStringCommand, "size", DbType.Int32, postedFile.ContentLength);
                            database.AddInParameter(sqlStringCommand, "time", DbType.DateTime, DateTime.Now);
                            database.AddInParameter(sqlStringCommand, "time1", DbType.DateTime, DateTime.Now);
                            database.ExecuteNonQuery(sqlStringCommand);
                        }
                    }
                    catch
                    {
                        this.showError("保存文件出错!");
                    }
                    string str9 = base.Request.Url.ToString();
                    str9 = str9.Substring(0, str9.IndexOf("/", 7));
                    if (base.Request.ApplicationPath != "/")
                    {
                        str9 = str9 + base.Request.ApplicationPath;
                    }
                    Hashtable hashtable = new Hashtable();
                    hashtable["error"] = 0;
                    hashtable["url"]   = str9 + str8;
                    base.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                    base.Response.Write(JsonMapper.ToJson(hashtable));
                    base.Response.End();
                }
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (ManagerHelper.GetCurrentManager() == null)
     {
         this.showError("您没有权限执行此操作!");
     }
     else
     {
         this.savePath = "~/Storage/master/gallery/";
         this.saveUrl  = "/Storage/master/gallery/";
         int result = 0;
         if (base.Request.Form["fileCategory"] != null)
         {
             int.TryParse(base.Request.Form["fileCategory"], out result);
         }
         string str = string.Empty;
         if (base.Request.Form["imgTitle"] != null)
         {
             str = base.Request.Form["imgTitle"];
         }
         HttpPostedFile postedFile = base.Request.Files["imgFile"];
         if (postedFile == null)
         {
             this.showError("请先选择文件!");
         }
         else if (!ResourcesHelper.CheckPostedFile(postedFile, "image"))
         {
             this.showError("不能上传空文件,且必须是有效的图片文件!");
         }
         else
         {
             string path = base.Server.MapPath(this.savePath);
             if (!Directory.Exists(path))
             {
                 this.showError("上传目录不存在。");
             }
             else
             {
                 path         = path + string.Format("{0}/", DateTime.Now.ToString("yyyyMM"));
                 this.saveUrl = this.saveUrl + string.Format("{0}/", DateTime.Now.ToString("yyyyMM"));
                 if (!Directory.Exists(path))
                 {
                     Directory.CreateDirectory(path);
                 }
                 string fileName = postedFile.FileName;
                 if (str.Length == 0)
                 {
                     str = fileName;
                 }
                 string str4     = Path.GetExtension(fileName).ToLower();
                 string str5     = DateTime.Now.ToString("yyyyMMddHHmmss_ffff", DateTimeFormatInfo.InvariantInfo) + str4;
                 string filename = path + str5;
                 string str7     = this.saveUrl + str5;
                 try
                 {
                     postedFile.SaveAs(filename);
                     Database  database         = DatabaseFactory.CreateDatabase();
                     DbCommand sqlStringCommand = database.GetSqlStringCommand("insert into Hishop_PhotoGallery(CategoryId,PhotoName,PhotoPath,FileSize,UploadTime,LastUpdateTime)values(@cid,@name,@path,@size,@time,@time1)");
                     database.AddInParameter(sqlStringCommand, "cid", DbType.Int32, result);
                     database.AddInParameter(sqlStringCommand, "name", DbType.String, str);
                     database.AddInParameter(sqlStringCommand, "path", DbType.String, str7);
                     database.AddInParameter(sqlStringCommand, "size", DbType.Int32, postedFile.ContentLength);
                     database.AddInParameter(sqlStringCommand, "time", DbType.DateTime, DateTime.Now);
                     database.AddInParameter(sqlStringCommand, "time1", DbType.DateTime, DateTime.Now);
                     database.ExecuteNonQuery(sqlStringCommand);
                 }
                 catch
                 {
                     this.showError("保存文件出错!");
                 }
                 Hashtable hashtable = new Hashtable();
                 hashtable["error"] = 0;
                 hashtable["url"]   = Globals.ApplicationPath + str7;
                 base.Response.AddHeader("Content-Type", "text/html; charset=UTF-8");
                 base.Response.Write(JsonMapper.ToJson(hashtable));
                 base.Response.End();
             }
         }
     }
 }