PHP中的MAX_FILE_SIZE-有什么意义? [英] MAX_FILE_SIZE in PHP - what's the point?

查看:89
本文介绍了PHP中的MAX_FILE_SIZE-有什么意义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图制作一个文件上载表格,并检查了PHP文档以刷新我在该主题上的记忆. 此处是相关文章的链接.突然我注意到了这则消息:

I was trying to make a file upload form and checked the PHP documentation to refresh my memory on the subject. Here is a link to the relevant article. All of a sudden I noticed this message:

MAX_FILE_SIZE隐藏字段(以字节为单位)必须在文件输入字段之前,其值是PHP接受的最大文件大小.应该始终使用此表单元素,因为它为用户省去了等待传输大文件而发现文件太大而传输失败的麻烦.请记住:在浏览器端愚弄此设置非常容易,因此切勿依赖此功能阻止更大文件的访问.对于在应用程序客户端的用户来说,它只是一个便利功能.但是,不能欺骗最大服务器端的PHP设置(在服务器端).

The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted by PHP. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too large and the transfer failed. Keep in mind: fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. It is merely a convenience feature for users on the client side of the application. The PHP settings (on the server side) for maximum-size, however, cannot be fooled.

好的...说什么?首先,它告诉它必须在文件上传字段之前.然后,它告诉我们这仅仅是为了方便.而且-无论如何,它都在客户端,因此任何人都可以使用它.谷歌搜索之后,我还发现没有已知的浏览器支持它.

OK... Say what? First it tells that it must precede the file upload field. Then it tells us that it is merely for convenience. And besides - it's on client side anyway so anyone can mess with it. After googling around I also found information that there are no known browsers that support it.

WTF?为什么说它(在所有意图和目的上)绝对毫无意义,必须必须在文件上传字段之前?我应该把它放在我的HTML中吗?

WTF? Why is it said that it must precede the file upload field if it seems to be (for all intents and purposes) absolutely pointless? Should I bother putting it in my HTML at all?

推荐答案

目前,没有浏览器真正关心MAX_FILE_SIZE指令,因此它毫无意义.我想它确实使您可以更精确地控制上传的最大大小(如上面的海报所述),而不是使用php.ini,但是我个人只是忽略了它,您也应该这样做.当然,这不会阻止用户上传比要求的文件大的文件-手册在这方面有误导性.

At the moment there are no browsers that actually care about the MAX_FILE_SIZE directive so it is pretty pointless. I suppose it does give you more granular control over max sizes on upload (as the poster above stated) rather than going with php.ini's, but personally I just ignore it, and you probably should too. It will certainly not stop a user uploading a larger than required file - the manual is fairly misleading in this regard.

这篇关于PHP中的MAX_FILE_SIZE-有什么意义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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