简体   繁体   English

PHP 警告:8978294 字节的 POST 内容长度超出第 0 行未知中 8388608 字节的限制

[英]PHP Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

I am getting this error when trying to upload an import on WordPress on my XAMPP local dev environment:在我的 XAMPP 本地开发环境中尝试在 WordPress 上传导入时出现此错误:

Warning: POST Content-Length of 8978294 bytes exceeds the limit of 8388608 bytes in Unknown on line 0警告:8978294 字节的 POST 内容长度超出第 0 行未知中 8388608 字节的限制

I changed the upload_max_filesize from 2M to 1000M , but that didn't seem to do anything.我将upload_max_filesize2M更改为1000M ,但这似乎没有任何作用。

Any ideas?有任何想法吗?

8388608 bytes is 8M, the default limit in PHP. 8388608 字节为 8M,PHP 中的默认限制。 Update your post_max_size in php.ini to a larger value.将 php.ini 中的post_max_size更新为更大的值。

upload_max_filesize sets the max file size that a user can upload while post_max_size sets the maximum amount of data that can be sent via a POST in a form. upload_max_filesize设置用户可以上传的最大文件大小,而post_max_size设置可以通过表单中的 POST 发送的最大数据量。

So you can set upload_max_filesize to 1 meg, which will mean that the biggest single file a user can upload is 1 megabyte, but they could upload 5 of them at once if the post_max_size was set to 5.因此,您可以将upload_max_filesize设置为1 meg,这意味着用户可以上传的最大单个文件为1 MB,但如果post_max_size设置为5,则他们可以一次上传5 个。

Changes will take effect after a restart of the server.更改将在服务器重新启动后生效。

Just set these in php.ini:只需在 php.ini 中设置这些:

upload_max_filesize = 1000M;
post_max_size = 1000M;

1. First u will find the php.ini file. 1.首先你会找到 php.ini 文件。

u can find php.ini file from this path.你可以从这个路径找到php.ini文件。 C:\\xampp\\php or from xampp folder. C:\\xampp\\php或来自xampp文件夹。

2. Now open php.ini file and change the following: 2.现在打开 php.ini 文件并更改以下内容:

1. post-max-size (change 8M to 800M ). 1. post-max-size (将8M改为800M )。

2. upload-max-filesize (change 2M to 2000M ). 2.上传-MAX,文件大小(2M变到2000M)。

3. Now stop the Apache server and MySQL. 3.现在停止 Apache 服务器和 MySQL。

4. Now restart Apache server and MySQL. 4.现在重启 Apache 服务器和 MySQL。

It worked fine after that.在那之后它工作得很好。

Enjoy ur working now :)享受你现在的工作:)

That's an 8MB post_max_size error.这是一个 8MB 的post_max_size错误。

Set it to a value you're comfortable with.将其设置为您感到满意的值。

Already restarted your Webserver?已经重新启动了您的网络服务器?

This will force php to reload the php.ini这将强制 php 重新加载php.ini

You will have to change the value of你将不得不改变的价值

post-max-size
upload-max-filesize

both of which you will find in php.ini两者都可以在php.ini 中找到

Restarting your server will help it start working.重新启动您的服务器将有助于它开始工作。 On a local test server running XAMIP, i had to stop the Apache server and restart it.在运行 XAMIP 的本地测试服务器上,我不得不停止 Apache 服务器并重新启动它。 It worked fine after that.在那之后它工作得很好。

Go to C:\\xamppp\\php .转到C:\\xamppp\\php Set these values in php.ini:在 php.ini 中设置这些值:

upload_max_filesize = 1000M
post_max_size = 0M
  1. Create new text file in your wp-admin directory root and name it info.php .在您的wp-admin目录根目录中创建新的文本文件并将其命名为info.php

  2. Open info.php and add this line:打开info.php并添加以下行:

    <?php phpinfo(); ?>

  3. Save it.保存。

  4. Go to yourwebsitename(probably localhost)/wp-admin/info.php in any web-browser.在任何网络浏览器中转到您的网站yourwebsitename(probably localhost)/wp-admin/info.php

  5. On the 8th line you will see: Configuration File (php.ini) Path , in my case it is C:\\Windows , meaning it is located on my C drive.在第 8 行,您将看到: Configuration File (php.ini) Path ,在我的情况下是C:\\Windows ,这意味着它位于我的 C 驱动器上。

  6. In the 9th line you will see: Loaded Configuration File , and next to it is written C:\\xampp\\php.ini在第 9 行你会看到: Loaded Configuration File ,旁边写着C:\\xampp\\php.ini

So I found my php.ini page that is associated with my wordpress web-site.所以我找到了与我的 wordpress 网站相关联的php.ini页面。

  1. Go to that path, and find php.ini .转到该路径,并找到php.ini

  2. Open it, and edit:打开它,然后编辑:

    Search for post_max_size=8M , and change it to post_max_size=1000M搜索post_max_size=8M ,并将其更改为post_max_size=1000M

    Search for upload_max_filesize=2M , and change it to upload_max_filesize=1000M搜索upload_max_filesize=2M ,修改为upload_max_filesize=1000M

  3. Go back to your Admin page → Media → Add New返回您的管理页面 → 媒体 → 添加新

  4. On the bottom you will see that 2MB has changed to 1000M.在底部您会看到 2MB 已更改为 1000M。

Once you done this process then you must restart your web server or just restart your computer.完成此过程后,您必须重新启动 Web 服务器或重新启动计算机。

Go to

C:\drive\xampp(where xampp installed)

simply find php.ini file then in the file search只需找到 php.ini 文件,然后在文件搜索中

post_max_size=XXM
upload_max_size=XXM

Change with this code使用此代码更改

post_max_size=100M
upload_max_filesize=100M

Don't forget to restart the xampp不要忘记重新启动xampp

Using wamp do the following and hopefully, it will resolve an issue使用 wamp 执行以下操作,希望它能解决问题

Make these changes in PHP Options to correct:在 PHP 选项中进行这些更改以更正:

max_execution_time   180

memory_limit   512M or your highest available

post_max_size  32M

upload_max_filesize   64M
  1. Find php.ini [\\xampp\\php]找到 php.ini [\\xampp\\php]
  2. Just set these in php.ini:只需在 php.ini 中设置这些:
upload_max_filesize = 1000M;
post_max_size = 1000M;
  1. Rebot server机器人服务器
    • Stop Apache and MySQL停止 Apache 和 MySQL
    • Start again Apache and MySQL重新启动 Apache 和 MySQL

您还需要更改post-max-size

From the XAMPP panel, click on the ADMIN button on the Apache site.在 XAMPP 面板中,单击 Apache 站点上的 ADMIN 按钮。 Then choose to edit php.ini And add the missing post_max_size to a value you are comfortable with.然后选择编辑 php.ini 并将缺失的 post_max_size 添加到一个你觉得合适的值。

post_max_size = 100M

Go to

C:\ drive

or that drive where xampp is installed click on xampp find php and open it , there you find php.ini folder open php.ini file with notepad and find upload_max_filesize and post_max_size in both "up and down find option",change both values to 1000M或者安装xampp的那个驱动点击xampp找到php并打开它,你会发现php.ini文件夹用记事本打开php.ini文件并在“向上和向下查找选项”中找到upload_max_filesizepost_max_size ,将两个值都更改为1000M

I have fixed same issue by changing below parameters to expected value in /etc/php/7.2/apache2/php.ini file我通过在/etc/php/7.2/apache2/php.ini文件中将以下参数更改为预期值来解决相同的问题

upload_max_filesize = 8M;
post_max_size = 8M;
upload_max_filesize = 8M;
post_max_size = 8M;

Imagine you already changed above values.假设您已经更改了上述值。 But what happen when user try to upload large files greater than 8M ?但是当用户尝试上传大于 8M 的大文件时会发生什么?

This is what happen, PHP shows this warning!这就是发生的事情,PHP 显示此警告!

Warning: POST Content-Length of x bytes exceeds the limit of y bytes in Unknown on line 0

you can avoid it by adding你可以通过添加来避免它

ob_get_contents();
ob_end_clean();

You have 2 options for this error:对于此错误,您有 2 个选项:

  1. The file you are uploading is too big, which you need to use smaller file.您上传的文件太大,您需要使用较小的文件。
  2. Increase the upload size in php.ini to将 php.ini 中的上传大小增加到

upload_max_filesize = 9M; post_max_size = 9M;

You might not be uploading the right zip file.您可能没有上传正确的 zip 文件。 In my case, as a newbie to wordpress(I used to do hardcoding), I installed the zipped file that contained another zip file which is the actual theme neede to be upload.就我而言,作为 wordpress 的新手(我曾经做过硬编码),我安装了包含另一个 zip 文件的压缩文件,这是要上传的实际主题。 So what what need to do in this case is to unzip the file and locate the "theme_name.zip" inside.那么在这种情况下需要做的是解压文件并找到里面的“theme_name.zip”。

Go to browser and search for php.ini and then open it, and change these two values:转到浏览器并搜索php.ini然后打开它,并更改这两个值:

post_max_size= 1000000000000M
upload_max_filesize= 10000000000000M

If you open the php.ini file using notepad , you can search for these two values by clicking:如果使用记事本打开php.ini文件,则可以通过单击来搜索这两个值:
cmd + f cmd + f

If changing the post_max_size settings from XAMPP folders.如果从XAMPP文件夹更改 post_max_size 设置。 It did not work for you try this.它不适合你试试这个。

From XAMPP control panel, click config then PHP (php.ini) and edit post_max_size and upload_max_filesize to a higher number in this file instead.XAMPP控制面板中,依次单击配置和PHP (php.ini)并将post_max_sizeupload_max_filesize编辑为该文件中更高的数字。 Stop Apache server.停止 Apache 服务器。 Start Apache server.启动 Apache 服务器。 This worked for me.这对我有用。

If your objective is to import a theme into your Wordpress then you can manually copy paste your theme into your wp-content->themes folder and extract it of course.如果您的目标是将主题导入 Wordpress,那么您可以手动将主题复制粘贴到 wp-content->themes 文件夹中,然后解压缩。 I just encountered this and couldn't locate the php.ini file for WAMP.我刚刚遇到了这个问题,但找不到 WAMP 的 php.ini 文件。

I have solved my php7 issues on centos 7 by updating /etc/php.ini with these settings:我已经通过使用以下设置更新/etc/php.ini解决了我在 centos 7 上的 php7 问题:

 post_max_size = 500M
 upload_max_filesize = 500M

As Optimaz ID pointed out, the code below helped me hide the PHP error message in a case where the user uploads a file larger than the upload_max_filesize and post_max_size set in php.ini (which is almost impossible when a large value is set).正如Optimaz ID指出的那样,在用户上传的文件大于 php.ini 中设置的 upload_max_filesize 和 post_max_size 的情况下,下面的代码帮助我隐藏了 PHP 错误消息(设置大值时几乎不可能)。

ob_get_contents();
ob_end_clean();

What worked for me was setting the value in Wamp, I clicked the icon -> PHP -> Php Settings and changed the values for post_max_size and upload_max_filesize对我有用的是在 Wamp 中设置值,我单击图标 -> PHP -> Php 设置并更改 post_max_size 和 upload_max_filesize 的值

for anyone running PHPMyAdmin inside of docker. Set the UPLOAD_LIMIT value in the env对于在 docker 中运行PHPMyAdmin的任何人。在环境中设置UPLOAD_LIMIT

from the docs https://github.com/phpmyadmin/docker#environment-variables-summary来自文档https://github.com/phpmyadmin/docker#environment-variables-summary

UPLOAD_LIMIT - if set, this option will override the default value for apache and php-fpm (format as [0-9+](K,M,G) default value is 2048K, this will change upload_max_filesize and post_max_size values) UPLOAD_LIMIT - 如果设置,此选项将覆盖 apache 和 php-fpm 的默认值(格式为[0-9+](K,M,G)默认值为 2048K,这将更改upload_max_filesizepost_max_size值)

docker-compose.yml example: docker-compose.yml 示例:

phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
      - UPLOAD_LIMIT=300M

normal docker run:正常docker运行:

sudo docker run .... -e UPLOAD_LIMIT=300M

For both of these options you have to rebuild the container对于这两个选项,您都必须重建容器

暂无
暂无

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

相关问题 处理得很好“POST内容 - 字节长度超过”警告限制 - Handle nicely “POST Content-Length of bytes exceeds the limit of” warning 在XAMPP POST上使用Wordpress的内容长度为26896206字节超出了200个字节的限制 - Using Wordpress on XAMPP POST Content-Length of 26896206 bytes exceeds the limit of 200 bytes POST内容长度超过了Wordpress的限制 - POST Content-Length exceeds the limit Wordpress 主题上传时,POST内容限制超过 - POST content limit exceeds at the time of theme upload WordPress 致命错误:第 1832 行的 wp-includes/wp-db.php 中允许的内存大小为 536870912 字节(试图分配 77 字节) - WordPress Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 77 bytes) in wp-includes/wp-db.php on line 1832 Woocommerce: Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /wp-includes/wp-db.php on line 2720 - Woocommerce: Fatal error: Allowed memory size of 1073741824 bytes exhausted (tried to allocate 20480 bytes) in /wp-includes/wp-db.php on line 2720 随机图像上传0字节PHP - Randomly Images are uploaded of 0 bytes PHP WordPress 网站在页面顶部显示“内容长度:” - WordPress Site showing “Content-Length: ” At top of Page 502使用标题内容长度时网关错误 - 502 Bad Gateway When Using Header Content-Length 警告:count() 在我的 single.php 中获取 wordpress 帖子的内容 - Warning: count() getting content of wordpress post in my single.php
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM