JS simple file upload instance code (no plug in required)

  • 2020-03-29 23:46:43
  • OfStack

<span class="up-btn" id="selectFile"> Please select file </span>
<input type="file" name="fileupload" style="FILTER: alpha(opacity=0); moz-opacity: 0; opacity: 0;" />

// click #selectFile to trigger the click event of input:file

  var ie = !-[1,]; 


Select the event that the file will fire



1. In the chrome browser, the hidden input: file cannot trigger the "click" event for data security.   So set the transparency of the input: file to hide it.

Related articles: