POST 内容-长度超过限制

当用户上传他们的文件时,我在 php 中的 error _ log 中也会出现类似的错误

PHP 警告: POST Content-长度为11933650字节,超过第0行 Unknown 中8388608字节的限制

在我的 php.ini (在 public _ html 中创建的自定义 ini 文件)中,这会解决这个问题吗? 我需要将它设置为大约1GB 吗?我将在 php.ini 中更改设置,它能解决这个问题吗?

upload_max_filesize = 1000M ;1GB
post_max_size = 1000M

我应该将“ memory _ limit”限制设置为什么。

在我的脚本中检查上传的文件大小是否小于1GB 也是正确的

if($_FILES["uploadedfile"]["size"]<1000000)
290320 次浏览

8388608 bytes is 8M, the default limit in PHP. Those changes to php.ini should indeed solve the problem (make sure your restart your Apache server after making them).

Memory limit shouldn't need to be changed here.

I suggest that you should change to post_max_size from 8M to 32M in the php.ini file.

you just setting at php.ini

then set :

upload_max_filesize = 1000M;
post_max_size = 1000M;

then restart your xampp.. Check the image

In Some cases, you need to increase the maximum execution time.

max_execution_time=30

I made it

max_execution_time=600000

then I was happy.

post_max_size should be slightly bigger than upload_max_filesize, because when uploading using HTTP POST method the text also includes headers with file size and name, etc.

If you want to successfully uppload 1GiB files, you have to set:

upload_max_filesize = 1024M
post_max_size = 1025M

Note, the correct suffix for GB is G, i.e. upload_max_filesize = 1G.

No need to set memory_limit.

Try pasting this to .htaccess and it should work.

php_value post_max_size 2000M
php_value upload_max_filesize 2500M
php_value max_execution_time 6000000
php_value max_input_time 6000000
php_value memory_limit 2500M

There might be more than just one php.ini file. For example, when using WAMP there are 2 php.ini files in following directories:

  • C:\wamp\bin\apache\apache2.4.9\bin
  • C:\wamp\bin\php\php5.5.12

You need to edit the first one.

If you are using Php 5.6.X versions in windows using Wamp, then file location may be in,

C:\Windows\php.ini

Just try with

post_max_size = 100M;

Try to do changes in Apache one. By that your Wamp/XAMP load .ini file

I disagree, but the solution to increase the file size in php.ini or .htaccess won't work if the user sends a file larger than allowed by the server application.

I suggest validating this on the front end. For example:

$(document).ready(function() {
$ ('#your_input_file_id').bind('change', function() {
var fileSize = this.files[0].size/1024/1024;
if (fileSize > 2) { // 2M
alert('Your custom message for max file size exceeded');
$('#your_input_file_id').val('');
}
});
});

If you are using Laravel and using artisan:serve for running Laravel project you create php.ini in your public directory, then you can specify your configuration.

  • file_uploads = On
  • max_execution_time = 300
  • post_max_size = 20480M
  • upload_max_filesize = 20480M