change text from an asp.net fileupload

0

Can you change the text inside FileUpload?

I wanted to change the text "No file selected"

    
asked by anonymous 03.05.2018 / 13:25

1 answer

1

There is no way to change this message in the text within input , each browser renders the element in its own way, but there is a way to use some workaround to solve. An alternative is to add a label that overlays the original, allowing you to use any text you want:

function fileChange() {
  var e = document.getElementById('file');
  if(e.value == "")
  {
      fileLabel.innerHTML = "Nenhum arquivo selecionado";
  }
  else
  {
      var theSplit = e.value.split('\');
      fileLabel.innerHTML = theSplit[theSplit.length-1];
  }

}

fileChange();
input[type=file]{
    color:transparent;
}

#fileLabel {
  margin-left: -160px
}
<div>
  <input type='file' title="Selecione um arquivo" id="file" onchange="fileChange()" >
   <label id="fileLabel">Nenhum arquivo selecionado</label>
 </div>
    
03.05.2018 / 13:44