Use the FileUpload control to upload the file.
<asp:fileupload id= "FileUpload1" runat= "Server"/>
The Accept= property ". Jpg,.jpeg,.png" setting can only be seen by the file type.
1. Upload command execution on the server
2, in JS control the size of the upload file
1<script type="Text/javascript">2document.getElementById ("Button1"). onclick =function () {3 varFL = document.getElementById ('FileUpload1');4 if(Fl.value.length <=0) {5document.getElementById ('Label1'). InnerHTML ="Please select the file you want to upload first!";6 return false;7 }8 Else {9 if (Fl.files[0].size > 1024x768 * 4) {Tendocument.getElementById ('Label1'). InnerHTML ="file too large, not allowed to exceed 4MB size! "; One return false; A } - } - } the</script>
3. Limit the size of uploaded files on the server
1 if 1024x768 1024x768 4 )2 {3 " file too large! "; 4 return ; 5 }
4. Limit the types of files you see :
Accept= ". Jpg,.jpeg,.png" To add this property setting in the control.
5. Expansion
In the <system.web> tag in Web. config
Change to
"2017-05-30" WebForm file Upload