3 回答

TA貢獻1786條經驗 獲得超11個贊
accept
input
使用
注:這些示例是基于當前規范編寫的,可能并不能在所有(或任何)瀏覽器中實際工作。規范也可能在將來發生變化,這可能會破壞這些示例。
h1 { font-size: 1em; margin:1em 0; }
h1 ~ h1 { border-top: 1px solid #ccc; padding-top: 1em; }
<h1>Match all image files (image/*)</h1>
<p><label>image/* <input type="file" accept="image/*"></label></p>
<h1>Match all video files (video/*)</h1>
<p><label>video/* <input type="file" accept="video/*"></label></p>
<h1>Match all audio files (audio/*)</h1>
<p><label>audio/* <input type="file" accept="audio/*"></label></p>
<h1>Match all image files (image/*) and files with the extension ".someext"</h1>
<p><label>.someext,image/* <input type="file" accept=".someext,image/*"></label></p>
<h1>Match all image files (image/*) and video files (video/*)</h1>
<p><label>image/*,video/* <input type="file" accept="image/*,video/*"></label></p>
來自HTML規范( 來源 )
這個 accept
屬性以向用戶代理提供將接受哪些文件類型的提示。
如果指定,則該屬性必須由 一組逗號分隔的令牌 ,其中每一個都必須是 ASCII大小寫不敏感 匹配下列之一:
弦 audio/*
指示接受聲音文件。
弦 video/*
指示接受視頻文件。
弦 image/*
指示接受圖像文件。 A
無參數的有效MIME類型
指示接受指定類型的文件。
一個字符串,其第一個字符是U+002E句號字符(.)
指示接受具有指定文件擴展名的文件。
- 3 回答
- 0 關注
- 600 瀏覽
相關問題推薦
添加回答
舉報