简体   繁体   English

本地 Wordpress 安装的最大上传大小限制为 10 MB

[英]Max upload size is limited to 10 MB on a local Wordpress installation

I have a local Wordpress installation at my work place using Wamp, and I had a max upload size of 3 MB.我在我的工作场所使用 Wamp 安装了本地 Wordpress,并且最大上传大小为 3 MB。
Following the solution I found, I edited the php.ini file from the wamp menu, increased post_max_size to 32M and upload_max_filesize to 64M and restarted the servers.按照我找到的解决方案,我从 wamp 菜单编辑了 php.ini 文件,将 post_max_size 增加到 32M,将 upload_max_filesize 增加到 64M,然后重新启动服务器。

The max upload size increased in the Wordpress admin area to 10 MB, which isn't enough, and I can't tell where that number is coming from. Wordpress 管理区域的最大上传大小增加到 10 MB,这还不够,我不知道这个数字来自哪里。

I searched for the phrase 10M in the wamp's php.ini file but didn't find any.我在 wamp 的 php.ini 文件中搜索了短语10M但没有找到。

Any idea where that number might be coming from?知道这个数字可能来自哪里吗?

Quote from the PHP manual引用自 PHP 手册

post_max_size integer post_max_size 整数

Sets max size of post data allowed.设置允许的帖子数据的最大大小。 This setting also affects file upload.此设置也会影响文件上传。 To upload large files, this value must be larger than upload_max_filesize.要上传大文件,此值必须大于upload_max_filesize。 If memory limit is enabled by your configure script, memory_limit also affects file uploading.如果您的配置脚本启用了内存限制,则 memory_limit 也会影响文件上传。 Generally speaking, memory_limit should be larger than post_max_size.一般来说,memory_limit 应该大于 post_max_size。 When an integer is used, the value is measured in bytes.使用整数时,该值以字节为单位。 Shorthand notation, as described in this FAQ, may also be used.也可以使用本常见问题解答中所述的速记符号。 If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty.如果 post 数据的大小大于 post_max_size,则 $_POST 和 $_FILES 超全局变量为空。 This can be tracked in various ways, eg by passing the $_GET variable to the script processing the data, ie , and then checking if $_GET['processed'] is set.这可以通过多种方式进行跟踪,例如通过将 $_GET 变量传递给处理数据的脚本,然后检查是否设置了 $_GET['processed']。

So your post_max_filesize need to be large enough to cope with the所以你的post_max_filesize需要足够大以应付

(upload_max_filesize * files uploaded) + other variables 

Also you need to check that memory_limit is big enough to cope as well您还需要检查memory_limit是否足够大以应对

The correct php.ini file正确的 php.ini 文件

It is also worth noting that WAMPServer, like most Apache/PHP installations has 2 different php.ini files.还值得注意的是,与大多数 Apache/PHP 安装一样,WAMPServer 有 2 个不同的 php.ini 文件。 Maybe you are editng the wrong one?也许你编辑错了?

There is one in \\wamp\\bin\\php\\php{version}\\php.ini this is used by the PHP CLI ( Command Line Inteface ) and soes not affect PHP used under Apache. \\wamp\\bin\\php\\php{version}\\php.ini有一个,它由 PHP CLI(命令行界面)使用,因此不会影响在 Apache 下使用的 PHP。

The one you need to edit to affect Apache/PHP is \\wamp\\bin\\apache\\apache{version}\\bin\\php.ini but the easiest way to do that is to use the wampmanager menus.您需要编辑以影响 Apache/PHP 的是\\wamp\\bin\\apache\\apache{version}\\bin\\php.ini但最简单的方法是使用 wampmanager 菜单。

Find the wampmanager icon in the system tray and left click then follow the menus在系统托盘中找到 wampmanager 图标并左键单击然后按照菜单操作

wampmanager -> PHP -> php.ini

This will open the correct php.ini file, the one used by PHP when run with apache.这将打开正确的php.ini文件,这是 PHP 在与 apache 一起运行时使用的文件。 Make the changes in this file.在此文件中进行更改。

Create a .htaccess file into the WordPress root and insert the following:在 WordPress 根目录中创建一个.htaccess文件并插入以下内容:

php_value post_max_size 64MB
php_value post_max_filesize 64MB
php_value upload_max_filesize 64MB

Then check if the values have been changed inside wp-admin .然后检查wp-admin的值是否已更改。 If they have, there is some other php.ini being loaded instead of the one you've been editing.如果有,则加载了其他一些php.ini而不是您一直在编辑的那个。

Still ran into this problem today.今天还是遇到了这个问题。 Fix that worked for me:修复对我有用:

Click WAMP tray icon and select PHP/php.ini单击 WAMP 托盘图标并选择 PHP/php.ini

This will open the php.ini file in the editor you chose when installing WAMP.这将在您安装 WAMP 时选择的编辑器中打开 php.ini 文件。 Note that php.ini is a shortcut to the file C:\\wampDir\\bin\\php\\php7.2.14\\phpForApache.ini.请注意,php.ini 是文件 C:\\wampDir\\bin\\php\\php7.2.14\\phpForApache.ini 的快捷方式。 Presumably this will vary between installs.据推测,这会因安装而异。

What I found was that the upload max in WP is the lesser of these 2 settings in the php.ini file:我发现 WP 中的最大上传是 php.ini 文件中这两个设置中较小的一个:

upload_max_filesize = 50M

and

post_max  = 45M

Easy!简单! (after over an hour of searching) ;( (经过一个多小时的搜索);(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM