ini_set("upload_max_filesize","200M") 在 php 中不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13442270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:27:23  来源:igfitidea点击:

ini_set("upload_max_filesize","200M") not working in php

file-uploadphp

提问by Maulik patel

Possible Duplicate:
overriding upload_max_filesize

可能重复:
覆盖upload_max_filesize

i use these code for change upload file size :-

我使用这些代码来更改上传文件大小:-

echo ini_get('upload_max_filesize').'<br/>';
ini_set("upload_max_filesize","300M");
echo ini_get("upload_max_filesize");

BUT I GOT

但我有

2M
2M

which is set in php.ini.

这是在 php.ini 中设置的。

i want to change file upload size limit.

我想更改文件上传大小限制。

回答by dev-null-dweller

  1. http://php.net/manual/en/ini.list.php
  1. http://php.net/manual/en/ini.list.php

upload_max_filesize "2M" PHP_INI_PERDIR

upload_max_filesize "2M" PHP_INI_PERDIR

  1. http://php.net/manual/en/configuration.changes.modes.php
  1. http://php.net/manual/en/configuration.changes.modes.php

PHP_INI_PERDIREntry can be set in php.ini, .htaccess, httpd.conf or .user.ini (since PHP 5.3)

PHP_INI_PERDIR条目可以在 php.ini、.htaccess、httpd.conf 或 .user.ini 中设置(自 PHP 5.3 起)

So you can't use ini_setfor this.

所以你不能用ini_set这个。

回答by Kelvin

You need to increase post_max_sizeas well.

你也需要增加post_max_size

To upload large files, this value must be larger than upload_max_filesize

上传大文件,这个值必须大于upload_max_filesize

You may also need to increase memory_limit

您可能还需要增加 memory_limit

If memory limit is enabled by your configure script, memory_limit also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size.

如果您的配置脚本启用了内存限制,则 memory_limit 也会影响文件上传。一般来说,memory_limit 应该大于 post_max_size。

As others have pointed out, upload_max_filesizecannot be changed at runtime (using ini_set). However, once you have changed it correctly you will still need to increase these values.

正如其他人指出的那样,upload_max_filesize不能在运行时更改(使用ini_set)。但是,一旦您正确更改了它,您仍然需要增加这些值

回答by lanzz

PHP documentationsays:

PHP 文档说:

The available options are K (for Kilobytes), M (for Megabytes) and G (for Gigabytes; available since PHP 5.1.0), these are case insensitive. Anything else assumes bytes. 1M equals one Megabyte or 1048576 bytes. 1K equals one Kilobyte or 1024 bytes. You may not use these shorthand notations outside of php.ini, instead use an integer value of bytes.

可用选项有 K(表示千字节)、M(表示兆字节)和 G(表示千兆字节;自 PHP 5.1.0 起可用),这些不区分大小写。其他任何东西都假定字节。1M 等于 1 兆字节或 1048576 字节。1K 等于 1 千字节或 1024 字节。您不能在 php.ini 之外使用这些速记符号,而是使用 bytes 的整数值