input accept屬性是用來限制上傳的文件格式
<input type="file" id="file" style="display:none;"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" />
<a href="javascript:selectFile()">加載本地excel文件</a>
function selectFile() {
document.getElementById('file').click();
}
<input text="file" accept=".csv" />
<input text="file" accept="application/vnd.ms-excel"/>
<input text="fiel" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>
<input type="file" accept="text/plain" />
<input type="file" accept="image/*" />
<input type="file" accept="text/html" />
- 7.上傳video(.avi, .mpg, .mpeg, .mp4)格式
<input type="file" accept="video/*" />
- 8.上傳audio(.mp3, .wav, etc)格式
<input type="file" accept="audio/*" />
<input type="file" accept=".pdf" />
<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel">