标签:event eve 上传 后台 rgs aws webform bsp 保存
前台代码
<body> <form id="form1" runat="server"> <div> <%--上传的控件--%> <asp:FileUpload ID="FileUpload1" runat="server" /> <%--上传按钮--%> <asp:Button ID="Button1" runat="server" Text="上传" /><br /> <%--提示是否验证成功--%> <asp:Image ID="Image1" runat="server" /> </div> </form> </body>
后台代码
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Drawing; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Button1.Click += Button1_Click; } void Button1_Click(object sender, EventArgs e) { //获得要上传的图片 System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.FileContent); //加上水印 Graphics g = Graphics.FromImage(img); string s = "WWW.ITNBA.COM"; Font f = new Font("微软雅黑", 30); Brush b = new SolidBrush(Color.Red); PointF pf = new PointF(50, 50); //注意所需要的参数,在上面创建出来 g.DrawString(s, f, b, pf); //保存下来 string path = "Uploads/" + DateTime.Now.ToString("yyyyMMddhhmmssms") + FileUpload1.FileName; img.Save(Server.MapPath(path)); Image1.ImageUrl = path; } }
标签:event eve 上传 后台 rgs aws webform bsp 保存
原文地址:http://www.cnblogs.com/hanqi0216/p/6978121.html