How do you get a HTML Browse button to filter and show only images?

后端 未结 6 2065
星月不相逢
星月不相逢 2021-01-21 09:31

On an HTML page, using the INPUT tag, how can you get it so that when you click the browse button that it filters for image files only? Bonus points if it can include .bmp fil

6条回答
  •  感情败类
    2021-01-21 10:25

    Use the "accept" attribute on your input tag.

    E.g.:

    
    

    EDIT: On further reading, it seems this isn't properly supported by any major browsers and therefore shouldn't be used. Instead it look like you'll need to use some sort of server-side or JavaScript validation instead.

提交回复
热议问题