Here's a very simple example of how to upload a file with asp+.
<script language= "VB" runat=server>
Sub Uploadbtn_click (Sender as Object, E as EventArgs)
UploadFile.PostedFile.SaveAs (Server.MapPath ("test.jpg"))
Myimage.imageurl = "Test.jpg"
Myimage.visible = True
End Sub
</script>
<body>
<form enctype= "Multipart/form-data" runat=server>
Select Upload file: <input id= "UploadFile" Type=file runat=server>
<asp:button text= "Upload me!" onclick= "Uploadbtn_click" runat=server/>
<asp:image id= "MyImage" Visible=false runat=server/>
</form>
</body>
Here's a more complex example, which enables your to upload a file, and then using the System.Drawing APIs
To resize/crop the image, overlay a custom text message onto the image, and then save it back out to disk
As a. JPG (note-this-sample works with *any* browser). I ' ve written this one in C #-but you would
Obviously be able to use VB or JScript to do it as:
<%@ Import namespace= "System.IO"%>
<%@ Import namespace= "System.Drawing"%>
<%@ Import namespace= "System.Drawing.Imaging"%>
<script language= "C #" runat=server>
void Uploadbtn_click (Object sender, EventArgs e) {
UploadFile.PostedFile.SaveAs (Server.MapPath ("test.jpg"));
Imageeditor.visible = true;
}
void Updatebtn_click (Object sender, EventArgs e) {
System.Drawing.Image Image = System.Drawing.Image.FromFile (Server.MapPath ("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));
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.