檔案輸入“接受”屬性 - 有用嗎? - File input 'accept' attribute - is it useful?

語言: CN / TW / HK

問題:

Implementing a file upload under html is fairly simple, but I just noticed that there is an 'accept' attribute that can be added to the <input type="file" ...> tag.在 html 下實現檔案上傳相當簡單,但我剛剛注意到有一個 'accept' 屬性可以新增到<input type="file" ...>標籤中。

Is this attribute useful as a way of limiting file uploads to images, etc?這個屬性作為限制檔案上傳到影象等的方式有用嗎? What is the best way to use it?使用它的最佳方法是什麼?

Alternatively, is there a way to limit file types, preferably in the file dialog, for an html file input tag?或者,有沒有辦法限制 html 檔案輸入標籤的檔案型別,最好是在檔案對話方塊中?


解決方案:

參考一: http://stackoom.com/question/l8o
參考二: File input 'accept' attribute - is it useful?
「其他文章」