Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the "No file chosen":

I have a button "Choose file" as follows (I am using Jade but it should be the same as Html5):

 input(type='file', name='videoFile') 

In the browser this shows a button with a text next to it "No file chosen". I would like to change the "No file chosen" text to something else, like "No video chosen" or "Choose a video please". I followed the first suggestions here:

I don't want to see 'no file chosen' for a file input field

But doing this did not change the text:

 input(type='file', name='videoFile', title = "Choose a video please") 

Can anybody help me figure out where the problem is?

like image 972
FranXh Avatar asked Apr 14 '13 16:04

FranXh


People also ask

How do I change no file selected?

Remove the value('No file chosen'). Use . addClass() method to add the class which removes the value “No file chosen”.

Can I change Choose file button text?

It's basically impossible to change the text of the native file input button.


2 Answers

Hide the input with css, add a label and assign it to input button. label will be clickable and when clicked, it will fire up the file dialog.

<input type="file" id="files" class="hidden"/> <label for="files">Select file</label> 

Then style the label as a button if you want.

like image 80
SKManX Avatar answered Nov 11 '22 13:11

SKManX


Try this its just a trick

<input type="file" name="uploadfile" id="img" style="display:none;"/> <label for="img">Click me to upload image</label> 

How it works

It's very simple. the Label element uses the "for" tag to reference to a form's element by id. In this case, we used "img" as the reference key between them. Once it is done, whenever you click on the label, it automatically trigger the form's element click event which is the file element click event in our case. We then make the file element invisible by using display:none and not visibility:hidden so that it doesn't create empty space.

Enjoy coding

like image 25
Odin Avatar answered Nov 11 '22 13:11

Odin