-1

The following code to style / hide an input type file is working in all browsers but Chrome.

<h5>Artikelliste hochladen:</h5>
<label for="uploadSkus">
    <button class="btn" id="add-article-list">
        <i class="icon icon-folder-open"></i> Liste auswählen
    </button>
</label>
<input type="file"
       name="uploadSkus" id="uploadSkus"
       class="articles-upload" style="display: none;">

Demo JSFiddle here.

I'm stuck on which minor detail is preventing Chrome from letting this work.

Tried playing arround with the display: none; without success. No errors or warnings in the console. Any idea ?

Daniel W.
  • 31,164
  • 13
  • 93
  • 151

3 Answers3

1

Use the hidden attr

    <h5>Artikelliste hochladen:</h5>
    <label for="uploadSkus">
        <button class="btn" id="add-article-list"><i class="icon icon-folder-open"></i> Liste auswählen</button>
    </label>
    <input type="file" name="uploadSkus" id="uploadSkus" class="articles-upload" hidden>
Gildas.Tambo
  • 22,173
  • 7
  • 50
  • 78
1

Have a look at this article: How can I remove the "No file chosen" tooltip from a file input in Chrome?

<h5>Artikelliste hochladen:</h5>
<label for="uploadSkus">
   <button class="btn" id="add-article-list"><i class="icon icon-folder-open"></i> Liste auswählen</button>
</label>
<input type="file" name="uploadSkus" id="uploadSkus" class="articles-upload" style="display: none;">

$('#add-article-list').click(function(){
   $("#uploadSkus").trigger('click');
})
Community
  • 1
  • 1
christianalfoni
  • 994
  • 8
  • 12
0

For me the problem was the display:none style on the input, the label works fine in firefox but didn't work in chrome.

To keep the hidden effect I removed the display:none style and add height: 0px; overflow: hidden; on the input.

NathanOliver
  • 171,901
  • 28
  • 288
  • 402