HTML:如何限制文件上传只能是图片? [英] HTML: How to limit file upload to be only images?
本文介绍了HTML:如何限制文件上传只能是图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< form method =postaction =...enctype =multipart / form-data>
< label for =image>照片< / label>
< input name =imagetype =file/>
< / form>
解决方案
HTML5表示< input type =fileaccept =image / *>
。当然,永远不要相信客户端验证:总是在服务器端再次检查...
With HTML, how do I limit what kind of filetypes can be uploaded?
To easy the user experience, I want to limit file uploads to be only images (jpeg, gif, png).
<form method="post" action="..." enctype="multipart/form-data">
<label for="image">Photo</label>
<input name="image" type="file" />
</form>
解决方案
HTML5 says <input type="file" accept="image/*">
. Of course, never trust client-side validation: Always check again on the server-side...
这篇关于HTML:如何限制文件上传只能是图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文