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

前端 未结 11 2229
盖世英雄少女心
盖世英雄少女心 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:48

    Use input tag with accept attribute

    
    

    Click here for the latest browser compatibility table

    Live demo here

    To select only image files, you can use this accept="image/*"

    
    

    Live demo here

    Only gif, jpg and png will be shown, screen grab from Chrome version 44

提交回复
热议问题