ASP+上载例子
点击次数:19 次 发布日期:2008-11-27 00:08:39 作者:源代码网
|
源代码网推荐 源代码网推荐 下面是用ASP+来纺写的上载例子!!在ASP中我们就才上载有许多组件: 源代码网推荐 源代码网推荐 <html> 源代码网推荐 源代码网推荐 <script language="VB" runat=server> 源代码网推荐 "VB代码 源代码网推荐 Sub UploadBtn_Click(Sender as Object, E as EventArgs) 源代码网推荐 "以http://www.aspcool.com/lanmu/test.jpg上载为例 源代码网推荐 UploadFile.PostedFile.SaveAs(Server.MapPath("http://www.aspcool.com/lanmu/test.jpg")) 源代码网推荐 源代码网推荐 MyImage.ImageUrl = "http://www.aspcool.com/lanmu/test.jpg" 源代码网推荐 源代码网推荐 MyImage.Visible = true 源代码网推荐 源代码网推荐 End Sub 源代码网推荐 源代码网推荐 </script> 源代码网推荐 源代码网推荐 <body> 源代码网推荐 源代码网推荐 <form enctype="multipart/form-data" runat=server> 源代码网推荐 源代码网推荐 <h3> 源代码网推荐 源代码网推荐 选择要上载的文件: 源代码网推荐 源代码网推荐 <input id="UploadFile" type=file runat=server name="file"> 源代码网推荐 源代码网推荐 <asp:button text="Upload Me!" onClick="UploadBtn_Click" runat=server/> 源代码网推荐 源代码网推荐 <hr> 源代码网推荐 源代码网推荐 <asp:image id="MyImage" visible=false runat=server/> 源代码网推荐 源代码网推荐 </form> 源代码网推荐 源代码网推荐 </body> 源代码网推荐 源代码网推荐 </html> 源代码网推荐 源代码网推荐 下面是一个更详细的例子,其可以上载文件!还用了 System.Drawing APIs 重新定议了图象, 同时还在图片上加上你的文字,我是用 C#编写的 -- 你也可以用VB、Jscript来写。 源代码网推荐 源代码网推荐 <%@ 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("http://www.aspcool.com/lanmu/test.jpg")); 源代码网推荐 ImageEditor.Visible = true; 源代码网推荐 } 源代码网推荐 源代码网推荐 void UpdateBtn_Click(Object sender, EventArgs e) 源代码网推荐 { 源代码网推荐 System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath("http://www.aspcool.com/lanmu/test.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("http://www.aspcool.com/lanmu/test.jpg"), ImageFormat.JPEG); 源代码网推荐 } 源代码网推荐 源代码网推荐 </script> 源代码网推荐 源代码网推荐 <body> 源代码网推荐 源代码网推荐 <form enctype="multipart/form-data" runat=server> 源代码网推荐 源代码网推荐 <h3> 源代码网推荐 源代码网推荐 选择要上载的文件: 源代码网推荐 <input id="UploadFile" type=file runat=server name="file2"> 源代码网推荐 源代码网推荐 <asp:button text="Upload Me!" onClick="UploadBtn_Click" runat=server/> 源代码网推荐 源代码网推荐 <hr> 源代码网推荐 <asp:panel id="ImageEditor" visible=false runat=server> 源代码网推荐 <img src="http://www.aspcool.com/lanmu/test.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="Update Image" onClick="UpdateBtn_Click" runat=server/> 源代码网推荐 </h3> 源代码网推荐 </asp:panel> 源代码网推荐 </form> 源代码网推荐 </body> 源代码网推荐 </html > 源代码网推荐 源代码网推荐 源代码网供稿. |
