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

后端 未结 6 2055
星月不相逢
星月不相逢 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 09:59

    Supposedly, you should use the "accept" attribute with the correct MIME type like so:

    
    

    Sadly, this isn't currently supported by any browsers. You can however validate the file using javascript afterwards. Here is a useful link with code: http://www.cs.tut.fi/~jkorpela/forms/file.html#filter

    Hope this helps!

提交回复
热议问题