input accept屬性限制文件上傳格式

上傳文件的類型;具體作法以下所示:html

注意:accept屬性能夠限制上傳格式,其有兼容性以下app

 

《1》上傳.csv格式的ide

<input text="file" accept=".csv" />excel

《2》上傳.xls格式orm

<input text="file"  accept="application/vnd.ms-excel"/>xml

《3》上傳.xslx格式htm

<input text="fiel" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"/>blog

《4》上傳.png/.jpg/etc格式圖片

<input type="file" accept="text/plain" />input

《5》上傳圖片格式

<input type="file" accept="image/*" />

《6》上傳.htm,.html格式

<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/*" />

《9》上傳.pdf格式

<input type="file" accept=".pdf" />

《10》若是限制兩種文件格式,同時限制

<input type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel">

注意:以逗號分隔開

相關文章
相關標籤/搜索