"2017-05-30" WebForm file Upload

Source: Internet
Author: User

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

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.