婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > asp.net圖片上傳實(shí)例

asp.net圖片上傳實(shí)例

熱門(mén)標(biāo)簽:宿遷智能外呼系統(tǒng)排名 ai電銷機(jī)器人對(duì)貸款有幫助嗎 廣州銷售外呼系統(tǒng)定制 地圖標(biāo)注多少錢(qián)一張 福州人工智能電銷機(jī)器人加盟 400電話辦理信任翰諾科技 電銷機(jī)器人 數(shù)據(jù) 云狐人工智能電話機(jī)器人 怎樣給陜西地圖標(biāo)注顏色

第一、圖片上傳,代碼如下:
xxx.aspx

復(fù)制代碼 代碼如下:

 td class="style1">
                asp:FileUpload ID="FileUpload1" runat="server"  />
                asp:Button ID="Button1" runat="server" Text="上傳一般圖片" onclick="Button1_Click" />
            /td>
            td class="style3">
                asp:Image ID="Image1" runat="server" Height="200px" Width="200px" />
            /td>


xxx.aspx.cs
復(fù)制代碼 代碼如下:

 protected void Button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i Request.Files.Count; i++)
            {
                HttpPostedFile file = Request.Files[i];
                if (file.ContentLength > 0)
                {
                    if (file.ContentType.Contains("image/"))
                    {
                        using (System.Drawing.Image img = System.Drawing.Image.FromStream(file.InputStream))
                        {
                            string FileName = System.IO.Path.GetFileName(file.FileName);
                            string[] SplitFileName = FileName.Split('.');
                            string AtterFileName = DateTime.Now.ToString("yyyMMddHHmmss")+"." + SplitFileName[1];
                            img.Save(Server.MapPath("/upload/" + AtterFileName));

                            this.Image1.ImageUrl = "upload/" + AtterFileName;
                        }
                    }
                    else
                    {
                        Response.Write("script>alert('該文件不是圖片格式!');/script>");
                    }
                }
                else
                {
                    Response.Write("script>alert('請(qǐng)選擇要上傳的圖片');/script>");
                }

            }
        }

第二、添加文字水印的圖片上傳,代碼如下:
xxx.aspx

復(fù)制代碼 代碼如下:

 td class="style1">
                asp:FileUpload ID="FileUpload2" runat="server" />
                asp:Button ID="Button2" runat="server" Text="上傳文字圖片" onclick="Button2_Click" />
            /td>
            td>
                asp:Image ID="Image2" runat="server" Height="200px" Width="200px" />
            /td>


xxx.aspx.cs
復(fù)制代碼 代碼如下:

 protected void Button2_Click(object sender, EventArgs e)
        {
            for (int i = 0; i Request.Files.Count; i++)
            {
                HttpPostedFile file = Request.Files[i];
                if (file.ContentLength > 0)
                {
                    if (file.ContentType.Contains("image/"))
                    {
                        using (System.Drawing.Image img = System.Drawing.Image.FromStream(file.InputStream))
                        {
                            using (Graphics g = Graphics.FromImage(img))
                            {
                                g.DrawString("我的圖片", new Font("宋體", 14), Brushes.Red, 0, 0);
                            }
                            string FileName = System.IO.Path.GetFileName(file.FileName);
                            string[] SplitFileName = FileName.Split('.');
                            string AtterFileName = DateTime.Now.ToString("yyyMMddHHmmss") + "." + SplitFileName[1];
                            img.Save(Server.MapPath("/upload/" + AtterFileName));
                            this.Image2.ImageUrl = "upload/" + AtterFileName;
                        }
                    }
                    else
                    {
                        Response.Write("script>alert('該文件不是圖片格式!');/script>");
                    }
                }
                else
                {
                    Response.Write("script>alert('請(qǐng)選擇要上傳的圖片');/script>");
                }

            }
        }

第三、添加圖片水印的圖片上傳,代碼如下:
xxx.aspx

復(fù)制代碼 代碼如下:

 td class="style1">
                asp:FileUpload ID="FileUpload3" runat="server" />
                asp:Button ID="Button3" runat="server" Text="上傳水印圖片" onclick="Button3_Click" />
            /td>
            td>
                asp:Image ID="Image3" runat="server" Height="200px" Width="200px" />
            /td>


xxx.aspx.cs
復(fù)制代碼 代碼如下:

protected void Button3_Click(object sender, EventArgs e)
        {
            for (int i = 0; i Request.Files.Count; i++)
            {
                HttpPostedFile file = Request.Files[i];
                if (file.ContentLength > 0)
                {
                    if (file.ContentType.Contains("image/"))
                    {
                        string fileName = file.FileName;
                        using (System.Drawing.Image img = System.Drawing.Image.FromStream(file.InputStream))
                        {
                            using (System.Drawing.Image imgWater = System.Drawing.Image.FromFile(Server.MapPath("/img/czlogo.jpg")))
                            {
                                using (Graphics g = Graphics.FromImage(img))
                                {
                                    g.DrawImage(imgWater, 0, 0);
                                }
                                string[] SplitFileName = fileName.Split('.');
                                string AtterFileName = DateTime.Now.ToString("yyyMMddHHmmss") + "." + SplitFileName[1];
                                img.Save(Server.MapPath("/upload/" + AtterFileName));
                                this.Image3.ImageUrl = "upload/" + AtterFileName;
                            }
                        }
                    }
                    else
                    {
                        Response.Write("script>alert('該文件不是圖片格式!');/script>");
                    }
                }
                else
                {
                    Response.Write("script>alert('請(qǐng)選擇要上傳的圖片');/script>");
                }
            }
        }

第四、上傳圖片濃縮圖,代碼如下:
xxx.aspx
復(fù)制代碼 代碼如下:

 td class="style1">
                asp:FileUpload ID="FileUpload4" runat="server" />
                asp:Button ID="Button4" runat="server" Text="上傳濃縮圖片" onclick="Button4_Click" />
            /td>
            td>
                asp:Image ID="Image4" runat="server" Height="200px" Width="200px" />
            /td>


xxx.aspx.cs
復(fù)制代碼 代碼如下:

 protected void Button4_Click(object sender, EventArgs e)
        {
            for (int i = 0; i Request.Files.Count; i++)
            {
                HttpPostedFile file = Request.Files[i];
                if (file.ContentLength > 0)
                {
                    if (file.ContentType.Contains("image/"))
                    {
                        using (System.Drawing.Image img = System.Drawing.Image.FromStream(file.InputStream))
                        {
                            using (System.Drawing.Image imgThumb = new Bitmap(200, 100))
                            {
                                using (Graphics g = Graphics.FromImage(imgThumb))
                                {
                                    g.DrawImage(img, new Rectangle(0, 0, imgThumb.Width, imgThumb.Height), new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
                                }
                                string fileName = file.FileName;
                                string[] SplitFileName = fileName.Split('.');
                                string AtterFileName = DateTime.Now.ToString("yyyMMddHHmmss") + "." + SplitFileName[1];
                                img.Save(Server.MapPath("/upload/" + AtterFileName));
                                this.Image4.ImageUrl = "upload/" + AtterFileName;
                            }
                        }
                    }
                    else
                    {
                        Response.Write("script>alert('該文件不是圖片格式!');/script>");
                    }
                }
                else
                {
                    Response.Write("script>alert('請(qǐng)選擇要上傳的圖片');/script>");
                }
            }

        }

您可能感興趣的文章:
  • JQuery.uploadify 上傳文件插件的使用詳解 for ASP.NET
  • asp.net+FCKeditor上傳圖片顯示叉叉圖片無(wú)法顯示的問(wèn)題的解決方法
  • asp.net fileupload控件上傳文件與多文件上傳
  • asp.net(c#)開(kāi)發(fā)中的文件上傳組件uploadify的使用方法(帶進(jìn)度條)
  • asp.net MVC實(shí)現(xiàn)無(wú)組件上傳圖片實(shí)例介紹
  • asp.net 多文件上傳,兼容IE6/7/8,提供完整代碼下載
  • Asp.net實(shí)現(xiàn)MVC處理文件的上傳下載功能實(shí)例教程
  • Asp.Net 無(wú)刷新文件上傳并顯示進(jìn)度條的實(shí)現(xiàn)方法及思路
  • asp.net下文件上傳和文件刪除的代碼
  • ASP.NET MVC Webuploader實(shí)現(xiàn)上傳功能

標(biāo)簽:焦作 新疆 曲靖 宜春 大興安嶺 綿陽(yáng) 黃南 延安

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《asp.net圖片上傳實(shí)例》,本文關(guān)鍵詞  asp.net,圖片,上傳,實(shí)例,asp.net,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《asp.net圖片上傳實(shí)例》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于asp.net圖片上傳實(shí)例的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 贵南县| 盐亭县| 永安市| 涿州市| 登封市| 芦溪县| 新昌县| 左云县| 萝北县| 句容市| 静乐县| 石泉县| 贞丰县| 西峡县| 东明县| 西林县| 桦川县| 广河县| 南华县| 伊吾县| 禹城市| 桐柏县| 德庆县| 长治县| 育儿| 北票市| 土默特左旗| 九江市| 和龙市| 青神县| 禹城市| 彭州市| 兴化市| 庆城县| 金山区| 湖南省| 牙克石市| 德昌县| 沈阳市| 凤冈县| 杨浦区|