I want to change default text on button that is "Choose File
" when we use input="file"
.
How can I do this? Also as you can see in image button is on left side of text. How can I put it on right side of text?
I want to change default text on button that is "Choose File
" when we use input="file"
.
How can I do this? Also as you can see in image button is on left side of text. How can I put it on right side of text?
I made a script and published it at GitHub: get selectFile.js Easy to use, feel free to clone.
HTML
JS
DEMO
jsfiddle.net/Thielicious/4oxmsy49/
Update 2017:
I have done research on how this could be achieved. And the best explanation/tutorial is here: https://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/
I'll write summary here just in case it becomes unavailable. So you should have HTML:
Then hide the input with CSS:
Then style the label:
Then optionally you can add JS to display the name of the file:
But really just read the tutorial and download the demo, it's really good.
Use
Below is the code to fetch name of the uploaded file"for"
attribute oflabel
forinput
.Using Bootstrap you can do this thing like below code.
I'd use a
button
to trigger theinput
:Quick and clean.
Each browser has it's own rendition of the control and as such you can't change either the text or the orientation of the control.
There are some "kind of" hacks you may want to try if you want an html/css solution rather than a Flash or silverlightsolution.
http://www.quirksmode.org/dom/inputfile.html
http://www.shauninman.com/archive/2007/09/10/styling_file_inputs_with_css_and_the_dom
Personally, because most users stick to their browser of choice, and therefore are probably used to seeing the control in the default rendition, they'd probably get confused if they saw something different (depending on the types of users you're dealing with).