在 PHP 上更改 upload_max_filesize

2023-12-02php开发问题
14

本文介绍了在 PHP 上更改 upload_max_filesize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在使用 PHP 5.3.0,并且遇到了一些可能是错误(在这种情况下我会报告它)或者可能是我的问题 - 所以我要求确认一下.

I'm using PHP 5.3.0 and have encountered something that might be a bug (in which case I'll report it) or might be me - so I'm asking to make sure.

运行此代码时:

<?php
ini_set('upload_max_filesize', '10M');
echo ini_get('upload_max_filesize'), ", " , ini_get('post_max_size')

我最终得到:

2M, 8M

尽管我的 php.ini 设置得更高:

This is despite my php.ini setting these higher:

upload_max_filesize = 10M
post_max_size = 10M

(只出现一次)

因为在设置值以及在 php.ini 中设置值之后发生错误,所以我倾向于认为这是一个错误.谁能确认或指出我哪里出错了?

Because the error occurs after setting the value as well as it being set in php.ini I'm inclined to think it's a bug. Can anyone confirm or point me where I'm going wrong?

更新:看起来重启 Apache 解决了这个问题 - 我一直认为如果你更改了 php.ini,它就不需要重启.

Update: Looks like restarting Apache fixed this - I always thought it didn't need to be restarted if you changed php.ini.

推荐答案

你不能使用 速记符号 在 PHP.ini 之外设置配置值.我认为当遇到错误值时,它会回落到 2MB 作为编译默认值.

You can't use shorthand notation to set configuration values outside of PHP.ini. I assume it's falling back to 2MB as the compiled default when confronted with a bad value.

另一方面,我不认为 upload_max_filesize 可以使用 ini_set() 设置.官方"列表声明它是 PHP_INI_PERDIR .

On the other hand, I don't think upload_max_filesize could be set using ini_set(). The "official" list states that it is PHP_INI_PERDIR .

这篇关于在 PHP 上更改 upload_max_filesize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17