如何获得HTML浏览按钮以仅过滤和显示图像? [英] How do you get a HTML Browse button to filter and show only images?

查看:47
本文介绍了如何获得HTML浏览按钮以仅过滤和显示图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在HTML页面上,使用INPUT标签,如何获取它,以便在单击浏览按钮时仅对图像文件进行过滤?如果可以包含.bmp文件,则可以加分.

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 files.

推荐答案

使用accept属性,列出要接受的mime类型.

With the accept attribute, you list the mime types to accept.

<form action="form_action.asp" accept="image/gif, image/jpeg">
    First name: <input type="text" name="fname" /><br />
    Last name: <input type="text" name="lname" /><br />
    Your image: <input type="file" name="pic" id="pic" /><br />
    <input type="submit" value="Submit" />
</form>

来自此处.

这篇关于如何获得HTML浏览按钮以仅过滤和显示图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆