0

I have an <input type="file">:

<input type="file" multiple="multiple" name="fileToUpload" id="fileToUpload">

If no files are selected, then the label says 'No files selected.' In case of a single selected file, the label next to it displays the file name. If more than one file is selected, it says 'n files selected.'

I was wondering if I could remove that label altogether, so there is only the button left?

Note that the label I'm talking about isn't visible in the DOM.

adder
  • 3,512
  • 1
  • 16
  • 28

2 Answers2

3

Put the input inside a label element, hide the input, and styled the label:

.file-upload {
  border: 1px solid black;
  border-radius: 3px;
  padding: 3px;
}

.file-upload input {
  overflow: hidden;
  width: 0;
}
<label class="file-upload">
  <input type="file" multiple="multiple" name="fileToUpload" id="fileToUpload">
  Choose Files
</label>
Ori Drori
  • 183,571
  • 29
  • 224
  • 209
0

Turn the font color transparent.

#fileToUpload {
  color: transparent;
  overflow: hidden;
}
<input type="file" multiple="multiple" name="fileToUpload" id="fileToUpload">
Carolaine
  • 1
  • 1