Bootstrap change the Upload file button style and display the uploaded filename

Source: Internet
Author: User

Reference blog:
HTML, the style customization used when uploading files <input type="file">


The <input type="file"> default style in HTML is ugly, using the style of the bootstrap button, and getting the filename to appear on its right

Gossip less, directly on the code:

<LabelFor="Jobdata"class="Control-label"style="FLOAT:LEFT;PADDING-LEFT:15PX;" > Task Data</Label><Divclass="Col-xs-12 col-sm-4 col-md-4" ><Divclass="File-container"style="Display:inline-block;position:relative;overflow:hidden;vertical-align:middle" ><buttonclass="Btn btn-success Fileinput-button"Type="button" > Upload</Button><InputType="File"Id="Jobdata"Onchange="LoadFile (This.files[0])"style="POSITION:ABSOLUTE;TOP:0;LEFT:0;FONT-SIZE:34PX; Opacity:0 "></div> <span id="filename" style="vertical-align:middle" > file not uploaded </span></div><script>function loadFile (file) {$$ (" #filename "). HTML (file.name);} </script>                 



Before uploading a file:

After uploading the file:

Bootstrap Change the Upload file button style and display the uploaded filename

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.