简体   繁体   English

如何限制用户在php中上传文件?

[英]How to restrict user to file upload in php ?

I have searched on this site and google. 我已经在这个网站和Google上进行了搜索。 I found a lots of suggestion about php upload restriction for user upload. 我发现了很多有关用户上传php的限制的建议。 Such as, check extension, getimagesize() 例如,检查扩展名, getimagesize()

or read file data and check if it is legal image or not etc etc. 或读取文件数据并检查其是否为合法图像等。

But my thinking is: if i create a .htaccess to execute only img file and rename the uploaded file then is it not enough for security ? 但是我的想法是:如果我创建一个.htaccess文件来仅执行img文件并重命名上载的文件,那么这对安全性还不够吗?

What's your opinion ? 你怎么看 ?

使用html 5时,您可以使用'accept'属性将上传内容限制为仅图像,音频或视频或mime_type。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM