跳到主要內容區塊
:::
首頁 文章分享列表 文章分享

HTML input上傳檔案類型限制accept

HTML使用input上傳檔案時,若想要限制檔案的類型時可以使用accept屬性。

指定副檔名

指定副檔名必須為csv

<input type="file" name="file" accept=".csv">

指定副檔名必須為pdf

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

指定副檔名為一個以上時,可以使用逗號分開

<input type="file" name="file" accept=".csv,.pdf">

指定為某種type

圖片類型:

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

HTML類型:

<input type="file" name="file" accept="text/html">

影片類型:

<input type="file" name="file" accept="video/*">

音訊類型

<input type="file" name="file" accept="audio/*">

 

這篇文章是否對您有幫助?
Line線上詢價 線上詢價
電子郵件
電話
聯繫我們