|
热门文章 |
|
|
|
相关文章 |
|
没有相关文章 |
|
|
ASP上传文件和图片 |
来源:本站原创 更新时间:2009/5/14 16:56:54 阅读次数:
字体:[大 中 小大 中 小大 中 小] 我要投稿 |
<%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Imaging" %> <html> <script language="C#" runat=server> void UploadBtn_Click(Object sender, EventArgs e) { UploadFile.PostedFile.SaveAs(Server.MapPath("chunfeng.jpg")); ImageEditor.Visible = true; } void UpdateBtn_Click(Object sender, EventArgs e) { System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath("chunfeng.jpg")); System.Drawing.Image newimage = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppRGB); Graphics g = Graphics.FromImage(newimage); g.DrawImage(image,0,0,image.Width,image.Height); Font f = new Font("Lucida Sans Unicode", Int32.Parse(FontSize.SelectedItem.Text)); Brush b = new SolidBrush(Color.Red); g.DrawString(Caption.Text, f, b, 10, 140); g.Dispose(); System.Drawing.Image thumbImage = newimage.GetThumbnailImage(Int32.Parse(Width.Text),Int32.Parse (Height.Text),null,0); image.Dispose(); thumbImage.Save(Server.MapPath("chunfeng.jpg"), ImageFormat.JPEG); } </script> <body> <form enctype="multipart/form-data" runat=server> <h3> 请选择上传文件: <input id="UploadFile" type=file runat=server> <asp:button Text="上传文件" OnClick="UploadBtn_Click" runat=server/> <hr> <asp:panel id="ImageEditor" Visible=false runat=server> <img src="chunfeng.jpg"> <h3> 图像宽度: <asp:textbox id="Width" runat=server/> 图像高度: <asp:textbox id="Height" runat=server/> <br> 文本标题: <asp:textbox id="Caption" runat=server/> 标题尺寸: <asp:dropdownlist id="FontSize" runat=server> <asp:listitem>14</asp:listitem> <asp:listitem>18</asp:listitem> <asp:listitem>26</asp:listitem> <asp:listitem>36</asp:listitem> <asp:listitem>48</asp:listitem> <asp:listitem>62</asp:listitem> </asp:dropdownlist> <asp:button Text="上传图片" OnClick="UpdateBtn_Click" runat=server/> </h3> </asp:panel> </form> </body> </html> |
上一篇文章: 生成目录树结构的ASP类下一篇文章: ASP上传一个图像文件 |
|
|