覆盖upload_max_filesize [英] overriding upload_max_filesize

查看:116
本文介绍了覆盖upload_max_filesize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在php中覆盖我的 upload_max_filesize ,但我仍然得到我的php.ini文件中的值为2 mb的值。

I am trying to override my upload_max_filesize in php but I still get the value which is in my php.ini file which is 2 mb.

ini_set('upload_max_filesize','30M');
ini_set('post_max_size','30M');
echo("<br>".ini_get('upload_max_filesize')."<br>");


推荐答案

这些设置在设置时不会有任何影响通过 ini_set

Those settings are not going to have any effect when set via ini_set.

原因是PHP需要之前的 甚至执行。当上传发生时,上传完成后执行目标脚本,因此PHP需要事先知道最大大小。

The reason is that PHP needs those values before your script is even executed. When an upload occurs, the target script is executed when the upload is complete, so PHP needs to know the maximum sizes beforehand.

将它们设置为 php.ini ,您的虚拟主机配置,或在 .htaccess 文件中。

Set them in php.ini, your virtual host config, or in a .htaccess file. A typical .htaccess file would look like this:

php_value post_max_size 30M
php_value upload_max_filesize 30M

这篇关于覆盖upload_max_filesize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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