Example #1
0
        protected void btnUploadPic_Click(object sender, EventArgs e)
        {
            string extention = System.IO.Path.GetExtension(FileUpLoadPic.FileName);

            DirectoryInfo dInfoAll = new DirectoryInfo(HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ArticleImage"]));

            if (!dInfoAll.Exists)
            {
                return;
            }
            foreach (var item in dInfoAll.GetFiles())
            {
                string idFile = item.Name.Substring(0, item.Name.Length - item.Extension.Length);
                if (idFile == Args.Article.Id.ToString())
                {
                    item.Delete();
                }
            }
            if (extention.ToLower() != ".jpg" && extention.ToLower() != ".png" && extention.ToLower() != ".gif" && extention.ToLower() != ".jpeg")
            {
                return;
            }
            string s = HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ArticleImage"] + Args.Article.Id.ToString() + extention);

            Args.Article.Link    = s;
            Session["LinkImage"] = Args.Article.Link;
            FileUpLoadPic.SaveAs(Args.Article.Link);
            divImg.InnerHtml = "<img src='/Temp/ArticleImage/" + Args.Article.Id + extention + "' />";
        }
Example #2
0
        protected void btnUploadPic_Click(object sender, EventArgs e)
        {
            string extention = System.IO.Path.GetExtension(FileUpLoadPic.FileName);
            string s         = HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ArticleImage"] + Guid.NewGuid().ToString() + extention);

            Args.Article.LinkImgPortlet = s;
            Session["LinkImgPortlet"]   = Args.Article.LinkImgPortlet;
            FileUpLoadPic.SaveAs(Args.Article.LinkImgPortlet);
        }
Example #3
0
        protected void btnUploadPic_Click(object sender, EventArgs e)
        {
            string pathFolder = HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["ImagePortlet"] + "/" + Args.ImagePortlet.DataId);

            if (!System.IO.Directory.Exists(pathFolder))
            {
                System.IO.Directory.CreateDirectory(pathFolder);
            }
            Args.ImagePortlet.Link = pathFolder + "/" + System.IO.Path.GetFileName(FileUpLoadPic.FileName);
            FileUpLoadPic.SaveAs(Args.ImagePortlet.Link);
            Session["ImageUrl"] = System.Configuration.ConfigurationManager.AppSettings["ImagePortlet"].Replace("~/", "") + "/" + Args.ImagePortlet.DataId + "/" + System.IO.Path.GetFileName(FileUpLoadPic.FileName);
        }