How can I remove the "No file chosen" tooltip from a file input in Chrome?

178,886

Solution 1

This is a native part of the webkit browsers and you cannot remove it. You should think about a hacky solution like covering or hiding the file inputs.

A hacky solution:

input[type='file'] {
  opacity:0    
}

<div>
    <input type='file'/>
    <span id='val'></span>
    <span id='button'>Select File</span>
</div>   

$('#button').click(function(){
   $("input[type='file']").trigger('click');
})

$("input[type='file']").change(function(){
   $('#val').text(this.value.replace(/C:\\fakepath\\/i, ''))
})    

Fiddle

Solution 2

The default tooltip can be edited by using the title attribute

<input type='file' title="your text" />

But if you try to remove this tooltip

<input type='file' title=""/>

This won't work. Here is my little trick to work this, try title with a space. It will work.:)

<input type='file' title=" "/>

Solution 3

For me, I just wanted the text to be invisible and still use the native browser button.

input[type='file'] {
  color: transparent;
}

I like all of undefined's suggestions but I had a different use case, hope this helps someone in the same situation.

Solution 4

I found a solution that is very easy, just set an empty string into the title attribute.

<input type="file" value="" title=" " />

Solution 5

Very easy, forget CSS targeting the input["type"] thing, it doesn't work for me. I don't know why. I got my solution in my HTML tag

<input type="file" style="color:transparent; width:70px;"/>

End of the problem

Share:
178,886
German Latorre
Author by

German Latorre

Clean code enthusiast since 1998, expertising C# and ASP.NET since 2003 and loving JavaScript since 2006, I am a serious web app developer and frustrated graphical designer. I love creating beautifully structured apps with any available technology (JavaScript, C# and modern PHP, mainly), and playing with any new framework or programming language as often as I can.

Updated on July 08, 2022

Comments

  • German Latorre
    German Latorre almost 2 years

    I would like to remove the "No file chosen" tooltip from a file input in Google Chrome (I see that no tooltip is displayed in Firefox).

    Please notice that I'm talking not about the text inside the input field, but about the tooltip that appears when you move the mouse over the input.

    I've tried this with no luck:

    $('#myFileInput').attr('title', '');
    
  • Dreen
    Dreen over 11 years
    I was going to post this, plus that there is a JQuery plugin that does a sort of similar thing filamentgroup.com/lab/…
  • German Latorre
    German Latorre over 11 years
    @RyanMcDonough, I can't see any tips about hiding the tooltip in the link you provided, is there anything I'm missing?
  • Ryan McDonough
    Ryan McDonough over 11 years
    Apologies, I should of clarified. As there is no way to hide that tooltip you will need to customise the input form control to achieve a similar result. In a sense hacking the original control.
  • German Latorre
    German Latorre over 11 years
    @Dreen, I can see the "No file chosen" tooltip in the link you provided as well, it does not solve the problem...
  • German Latorre
    German Latorre over 11 years
    Wow, that's bad news... Is there any documentation available that mentions this issue (I mean, te fact that you cannot remove that tooltip)?
  • Ram
    Ram over 11 years
    @antur123 “No file chosen” like browser's back and forth button is not a part of the DOM, JavaScript has no access to them, for this reason I don't think there is a documentation about this issue.
  • Arsen K.
    Arsen K. over 11 years
    Tooltip is still displayed, when you hover over the bottom edge of the input. "Opacity: 0" doesn't solve the problem.
  • Ram
    Ram over 11 years
    @Webars I have mentioned hacky, not bullet-proof.
  • Arsen K.
    Arsen K. over 11 years
    I understand. I'm looking for any solution, but no luck. :( Besides, browsers may block file dialog. So click on #button to open input:file - is a bad idea...
  • Arsen K.
    Arsen K. over 11 years
    Just tested your website in Chrome 24 (latest). As you can see, tooltip is displayed. screencast.com/t/75uHC6YyuGhO
  • MEM
    MEM about 11 years
    Didn't take away the "no file chosen" for me.
  • Nisanth Sojan
    Nisanth Sojan over 10 years
    the tooltip is still displayed
  • Ram
    Ram over 10 years
    @NisanthSojan So make it better, it was just an example.
  • Pawan Pillai
    Pawan Pillai about 10 years
    One of the cleanest hack I have seen. Hopefully it will work in all browsers like IE9+, FF, Safari. Runs perfectly in Chrome.
  • Brian
    Brian over 9 years
    this gets rid of the "no file chosen" for me
  • Brilliand
    Brilliand about 9 years
    @MEM, which browser are you on? This is working for me on Chrome (with some modifications because I don't just want the text to disappear).
  • Robert Siemer
    Robert Siemer over 8 years
    Works in Chromium Version 44.0.2403.89 and has no side-effects in version 40.0.3! Great input @simon
  • Admin
    Admin over 8 years
    Thanks for the edit. I'd like to find a solution without wedkitURL because it's deprecated.
  • Monicka
    Monicka over 8 years
    but your custom title will show up even after choosing files.
  • simon
    simon over 8 years
    I think there is simple solution. Check my answer below. I don't see anything simple than that. Also it works in all browsers.
  • yvesmancera
    yvesmancera about 8 years
    This answer is the only one that worked for me, just replaced the browser detection to the one provided in stackoverflow.com/questions/9847580/…
  • Admin
    Admin over 7 years
    this is a great solution ! it worked great for me because after uploading the file, the file name would show. nice and thank you!
  • 2540625
    2540625 over 7 years
    The title's box (containing the non-breaking space character) still appears, however.
  • Es Noguera
    Es Noguera about 7 years
    Hey, if you want to hide the "No file choosen" tooltip: use "display:none" style and then use click function when tap the button.
  • TonyLuigiC
    TonyLuigiC over 6 years
    I didn't see the solution below until now, since it was so far down the page. In any case, I'm not going to delete my solution, since hopefully the style color information will be useful (it resolved the Firefox issue for me).
  • Victor Bredihin
    Victor Bredihin over 6 years
    it's still says 'no file choosen' in your fiddle example
  • CETb
    CETb about 6 years
    You can hide with style: style='width: 0;overflow: hidden;opacity:0;filter:alpha(opacity=0);display: inline;position: absolute;'
  • AshD
    AshD about 6 years
    The title box does appear for me with an empty string on chrome.
  • AshD
    AshD about 6 years
    Did not work for me on chrome (the fiddle itself shows the no file chosen tooltip)
  • ConductedClever
    ConductedClever about 5 years
    I have integrated this solution with a binding engine (aureliajs, angular, ...) and this works very very fine to compute proper message and show to user.
  • ufukomer
    ufukomer about 5 years
    You should just make title="" otherwise title=" " shows a blank tooltip.
  • Xenalin
    Xenalin about 4 years
    This is the best answer for 2020. Setting opacity to 0 makes the whole element invisible.
  • The Fool
    The Fool about 4 years
    how is this removing the tooltip? I still see it
  • Craig Brown
    Craig Brown over 2 years
    This doesn't remove the tooltip that appears when you hover over the button, it just hides the text next to the button.