gpt4 book ai didi

php.ini max_upload_file 大小回落到默认 2M

转载 作者:行者123 更新时间:2023-11-29 11:08:24 25 4
gpt4 key购买 nike

我必须使用“备份和迁移”模块在 drupal-7 中上传 5.7MB 数据库。但是,当我上传文件时,它会抛出以下错误:

The file email839805758.zip could not be saved, because it exceeds 2 MB, the maximum allowed size for uploads.

我已更改 php.ini 文件中的 post_max_size = 20M 和 upload_max_filesize = 40M 并在/etc/php 中创建 user.ini/5.6/apache2/conf.d/user.ini。并粘贴 post_max_size 和 upload_max_filesize 大于 2M。我检查了 phpinfo()。它只是将默认值设置为 2M。有人对 drupal 7 中的此类场景有任何解决方案吗?

我在 drupal backup_migrate.module 文件中发现了一些可能是障碍的附加内容。帮我破解这个功能。

  /**
* A custom version of format size which treats 1GB as 1000 MB rather than 1024 MB
* This is a more standard and expected version for storage (as opposed to memory).
*/
function backup_migrate_format_size($size, $langcode = LANGUAGE_NONE) {
$precision = 2;
$multiply = pow(10, $precision);

if ($size == 0) {
return t('0 bytes', array(), array('langcode' => $langcode));
}
if ($size < 1024) {
return format_plural($size, '1 byte', '@count bytes', array(), array('langcode' => $langcode));
}
else {
$size = ceil($size * $multiply / 1024);
$string = '@size KB';
if ($size >= (1024 * $multiply)) {
$size = ceil($size / 1024);
$string = '@size MB';
}
if ($size >= 1000 * $multiply) {
$size = ceil($size / 1000);
$string = '@size GB';
}
if ($size >= 1000 * $multiply) {
$size = ceil($size / 1000);
$string = '@size TB';
}
return t($string, array('@size' => round($size/$multiply, $precision)), array('langcode' => $langcode));
}

}

最佳答案

在脚本中放入 phpinfo() 并查看您正在使用哪个 php.ini 文件。进入该文件并更改这些值。请记住,必须重新启动守护进程(php-fpm 或 apache)才能激活更改。

如果由于某种原因您不能这样做,您始终可以在本地使用 ini_set() 函数,但强烈建议不要这样做!

关于php.ini max_upload_file 大小回落到默认 2M,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41014824/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com