帶 capture 和 accept 屬性的 HTML 檔案輸入控制元件不能正常工作


使用 accept 屬性為 HTML 中伺服器接受的檔案型別設定。僅對 <input type="file"> 使用此屬性。

示例

你可以嘗試執行以下程式碼以使用 accept 屬性

<!DOCTYPE html>
<html>
   <head>      
   <title>File Upload Box</title>    
   </head>
   <body>
      <form>    
         <input type = "file" name = "fileupload" accept = "image/*" />  
      </form>
   </body>
</html>

capture 屬性是一個布林屬性,如果指定,則表示更傾向於直接從裝置擷取媒體...。

capture 屬性不是用來在對話方塊中包含攝像機選項,而是用來表示更傾向於直接從網路攝像頭擷取。

“正確”的程式碼如下

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

更新於: 2020 年 1 月 24 日

450 次檢視

職業生涯開啟

完成課程,獲得認證

開始
廣告
© . All rights reserved.