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: