Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename HTML "browse" button of an input type=file?

Tags:

html

How to rename the browse button as "Select the file"? E.g.:

<input type=file name=browse > 
like image 360
coderex Avatar asked Jul 22 '09 07:07

coderex


People also ask

How do I change the default text of an input type file?

call( inputs, function( input ) { var label = input. nextElementSibling, labelVal = label. innerHTML; input. addEventListener( 'change', function( e ) { var fileName = ''; if( this.

How do I customize my browser button?

you cannot directly customize the browse button. your CSS won't work upon it. What you can do is, you can create a button of yours with a textbox to the left of it. customize it, and upon click, trigger the original file upload.

How do I get the Browse option in HTML?

Definition and Usage. The <input type="file"> defines a file-select field and a "Browse" button for file uploads. To define a file-select field that allows multiple files to be selected, add the multiple attribute. Tip: Always add the <label> tag for best accessibility practices!


1 Answers

<script language="JavaScript" type="text/javascript"> function HandleBrowseClick() {     var fileinput = document.getElementById("browse");     fileinput.click(); } function Handlechange() { var fileinput = document.getElementById("browse"); var textinput = document.getElementById("filename"); textinput.value = fileinput.value; } </script>  <input type="file" id="browse" name="fileupload" style="display: none" onChange="Handlechange();"/> <input type="text" id="filename" readonly="true"/> <input type="button" value="Click to select file" id="fakeBrowse" onclick="HandleBrowseClick();"/> 

http://jsfiddle.net/J8ekg/

like image 94
Payam Shoeibi Avatar answered Oct 14 '22 21:10

Payam Shoeibi