Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML how to remove text in FileUpload field?

When I have a file upload field,

<form action="" method="post" enctype="multipart/form-data">
    <input id="image" type="file" name="image">
</form>

http://jsfiddle.net/jakeaustin5574/6DzgU/

It automatically creates a text "No file chosen" and a "Browse" button.

I want to change or remove this "No file chosen" text.

Is there anyway to achieve this in css or Javascript?

Thanks

like image 470
user2492270 Avatar asked Aug 23 '13 08:08

user2492270


People also ask

How do I remove something from a FileList?

One way to remove a file from a JavaScript FileList is to use the spread operator to convert the FileList to an array. Then we can call splice to remove the file we want.

How do you remove no file selected in file input?

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


1 Answers

First of all. You have to hide your input:

input#image{position:fixed;top:-100px;}

Secondly, you have to create alternative button with your skin:

<form action="" method="post" enctype="multipart/form-data">
   <input id="image" type="file" name="image">
   <button id="image_alt">Select image</button>
</form>

and the last step is to create a javascript script which link alternative button with original one:

document.getElementById('image_alt').addEventListener('click',function(){
    document.getElementById('image').click();
});

Example Fiddle

like image 67
David Avatar answered Oct 11 '22 12:10

David