Limit file format when using <input type=“file”>?

前端 未结 11 2418
盖世英雄少女心
盖世英雄少女心 2020-11-22 04:15

I\'d like to restrict the type of file that can be chosen from the native OS file chooser when the user clicks the Browse button in the

11条回答
  •  野性不改
    2020-11-22 04:49

    I may suggest following:

    • If you have to make user select any of image files by default, the use accept="image/*"

    • if you want to restrict to specific image types then use accept="image/bmp, image/jpeg, image/png"

    • if you want to restrict to specific types then use accept=".bmp, .doc, .pdf"

    • You cannot restrict user to change file filer to all files, so always validate file type in script and server

提交回复
热议问题