How to get file name when user select a file via <input type=“file” />?

前端 未结 4 1917
你的背包
你的背包 2020-11-27 15:55

I\'ve seen similar questions before,which ends up with no solution,because of security reasons.

But today I see hostmonster has successfully implemented this,when I

4条回答
  •  旧时难觅i
    2020-11-27 15:58

    You can use the next code:

    JS

        function showname () {
          var name = document.getElementById('fileInput'); 
          alert('Selected file: ' + name.files.item(0).name);
          alert('Selected file: ' + name.files.item(0).size);
          alert('Selected file: ' + name.files.item(0).type);
        };
    

    HTML

    
        

提交回复
热议问题