Private void Button1_Click (Object Sender, System.Eventargs E)
{
IF (file1.postedfile! = null)
{
// Upload file name (including full path)
String filename = file1.postedfile.filename;
// Upload the size of the file (byte)
INT filelength = file1.postedfile.contentLength;
String smsg = NULL;
/ / Judgment the file size is more than 200K
IF (FileLength> (200 * 1024)))
{
SMSG = filename "file exceeds 200k bytes!";
}
Else
{
// Take a file name
Filename = filename.substring (filename.lastindexof (@ "/"));
// Use the SaveAs method to save the file in the project path / UPLOAD directory
File1.postedFile.saveas (httpruntime.appdomainapppath @ "UPLOAD /" FileName);
SMSG = "successfully uploaded file:" filename "file size:" FileLength "byte" "file type:" file1.postedfile.contentType;
}
// Use JavaScript display of the operation result information