Fileupdate-upload Control

Source: Internet
Author: User
Protected void button#click (Object sender, eventargs E)
{
String name = fileupload1.filename; // Upload File Name
String size = fileupload1.postedfile. contentlength. tostring (); // file size (bytes)
String type = fileupload1.postedfile. contenttype; // obtain the mime content type of the uploaded file
String type1 = Name. substring (name. lastindexof (". ") + 1); // name. lastindexof (". ") index name ". "Location + 1, which is the suffix Index
String ipath = server. mappath ("upimg") + "\" + name;
String fpath = server. mappath ("upfile") + "\" + name;
String wpath = "upimg" + "\" + name;
If (type1 = "jpg" | type1 = "GIF" | type1 = "BMP" | type1 = "PNG ")
{
Fileupload1.saveas (ipath );
Image1.imageurl = wpath;
Label1.text = "file name" + name + "<br>" + "file size:" + size + "<br> file type:" + Type + "<br> suffix" + type1 + "<br> actual path" + ipath + "<br> virtual path" + wpath;
}
Else
{
Fileupload1.saveas (fpath );
Image1.imageurl = wpath;
Label1.text = "file name" + name + "<br>" + "file size:" + size + "<br> file type:" + Type + "<br> suffix" + type1 + "<br> actual path" + ipath + "<br> virtual path" + wpath;
}
}

Running result:

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.