protected void upimgmult_Click(object sender, EventArgs e)
    {
        if (this.FileUpload1.HasFile)
        {
            if (!Directory.Exists(HttpContext.Current.Server.MapPath("/") + @"/sqlimages/Album/" + id.Value))
            {
                //新增資料夾
                Directory.CreateDirectory(HttpContext.Current.Server.MapPath("/") + @"/sqlimages/Album/" + id.Value);
            }
            if (!Directory.Exists(HttpContext.Current.Server.MapPath("/") + @"/sqlimages/min_Album/" + id.Value))
            {
                //新增資料夾
                Directory.CreateDirectory(HttpContext.Current.Server.MapPath("/") + @"/sqlimages/min_Album/" + id.Value);
            }
            foreach (HttpPostedFile file in FileUpload1.PostedFiles)
            {
                string ext          = System.IO.Path.GetExtension(file.FileName);
                String FileName     = DateTime.Now.ToString("yyyyMMddHHmmss.fff") + ext;
                String SavePath     = Server.MapPath("/") + @"/sqlimages/Album/" + id.Value + "/" + FileName;
                String SavePath_min = Server.MapPath("~/sqlimages/min_Album/" + id.Value);
                DB_fountion.GenerateThumbnailImage(FileName, file.InputStream, SavePath_min, "", 100, 63);
                file.SaveAs(SavePath);
            }
        }

        DBinit();
    }
Exemple #2
0
    protected void Update_img(string Yachtsno)
    {
        if (FileUploadimg.HasFile)
        {
            if (!Directory.Exists(HttpContext.Current.Server.MapPath("~") + @"/sqlimages/Yachts/" + Yachtsno))
            {
                Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~") + @"/sqlimages/Yachts/" + Yachtsno);
            }

            FileUpload test         = FileUploadimg;
            string     ext          = System.IO.Path.GetExtension(test.FileName);
            String     filename     = "Img" + ext;
            String     SavePath     = "";
            String     SavePath_min = "";
            img_temp.Value = filename;//存回資料庫
            SavePath       = Server.MapPath("~/sqlimages/Yachts/" + Yachtsno + "/" + filename);
            SavePath_min   = Server.MapPath("~/sqlimages/Yachts/" + Yachtsno);
            img.ImageUrl   = "~/sqimages/Yachts/" + Yachtsno + "/" + filename;
            DB_fountion.GenerateThumbnailImage(filename, FileUploadimg.FileContent, SavePath_min, "min_", 240, 120);
            FileUploadimg.SaveAs(SavePath);
        }
    }