overriding upload_max_filesize(覆盖 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 文件中.典型的 .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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:覆盖 upload_max_filesize
基础教程推荐
- 主题化 Drupal 7 的 Ubercart “/cart"页 2021-01-01
- PHPUnit 的 Selenium 2 文档到底在哪里? 2022-01-01
- 将变量从树枝传递给 js 2022-01-01
- php 7.4 在写入变量中的 Twig 问题 2022-01-01
- 使用 scandir() 在目录中查找文件夹 (PHP) 2022-01-01
- Yii2 - 在运行时设置邮件传输参数 2022-01-01
- 如何在数学上评估像“2-1"这样的字符串?产生“1"? 2022-01-01
- Web 服务器如何处理请求? 2021-01-01
- php中的PDF导出 2022-01-01
- php中的foreach复选框POST 2021-01-01
