Anyone who has learned HTML knows that the upload control requires <input type = "file"/>. Of course, we also have corresponding server-side controls.
We only need to determine whether a file is uploaded and save it.
1:Protected VoidButton#click (ObjectSender, eventargs E)
2:{
3:StringSavepath =@ "D: \ uploads \";
4:
5:If (! Directory. exists (savepath ))
6:Directory. createdirectory (savepath );
7:If (fileupload1.hasfile)
8:{
9:String filename = fileupload1.filename;
10:Savepath + = filename;
11:Fileupload1.saveas (savepath );
12:Label1.text = "The uploaded files are:"+ Savepath;
13:
14:}
15:Else {
16:Label1.text = "the file to be uploaded is not specified ";
17:}
18:}
File Size upload restrictions
You can use web. config to configure the maxrequestlength = "10000" attribute. the upload will fail if the uploaded content exceeds the set value. We can also set the timeout time.