如何限制< input type =" file">所以它只能选择.pdf文件? [英] How to restrict <input type="file"> so that it can only select .pdf files?
本文介绍了如何限制< input type =" file">所以它只能选择.pdf文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
默认情况下,它可以选择所有类型的文件,如何限制它,以便它只能选择 .pdf
文件?
By default it can select all type of files,how to restrict it so that it can only select .pdf
files?
解决方案
接受属性,建议浏览器限制某些类型。但是,您需要在您的服务器端代码中重新验证以确保。永远不要相信客户给你的东西。
You can use the accept attribute on your form to suggest to the browser to restrict certain types. However, you'll want to re-validate in your server-side code to make sure. Never trust what the client sends you.
这篇关于如何限制< input type =" file">所以它只能选择.pdf文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文