I am getting the post too large exception when I try to upload files which are more than 2 MB in size and I've already tried everything like increasing the post_max_size and max_upload_size in php.ini file but I am still getting the same error. When I comment the handler function in validatepostsize.php file it shows token mismatch error:
I think you can check the following parameters in your php.ini file like:
upload_max_filesize = 40m
post_max_size = 50m
After restart your server like (apache)
Hope this work for you!
First, check your PHP version.
php -v
The command below will print the path to the php.ini file that your server is using.
php -i | grep php.ini
Next.
sudo nano /etc/php/7.4/cli/php.ini
The values of post_max_size, upload_max_filesize and memory_limit by default have the value of 8M, 2M, and 128M respectively.
Search for those variables and change their values, whilst ensuring that the sizes follow the same ratio as the default values.
See example below:
post_max_size = 2G
upload_max_filesize = 1G
memory_limit = 3G
For "heavy-loaded sites", it is useful to have FPM installed and running.
sudo apt install php7.4-fpm -y
sudo service php7.4-fpm start
Finally, restart your web server.
sudo service apache2 restart
One of the issues is that the Laravel PHP artisan serve local development server uses the php.ini under PHP/CLI instead of under PHP/apache2
So if you are having this issue while developing with PHP artisan serve, go and fetch the php.ini that's under the /etc/php[version]/cli folder.
Its not the best solution just to change parameters in php.ini and then restart apache:
upload_max_filesize = 128M
post_max_size = 128m
//or whatever value you think is right
Restart apache like this:
sudo service apache2 restart
The best way as for me is to catch PostTooLargeException using Error Handling of laravel: Error Handling
For a detailed answer how to catch PostTooLargeException using Error Handling you can see my answer in this thread: thread with full answer. I struggled like 2 days before I fully figured how to achieve that.
Happy coding!
Actually I am looking for the same answer for the same issue.
I have found out that the issue can be resolve with an edit of .htaccess file.
Add the below code in the file.
php_value upload_max_filesize 50M
php_value post_max_size 50M
This above two line will resolve the issue but if you are adding this much size then the line below give will save you from future issue. of like execution time expire and
all.
php_value max_input_time 120
php_value max_execution_time 120
For a more accurate validation, I recommend setting the values in bytes, because 50 MB is 52428800B, which actually 52 MB, not 5000000B.
.htaccess example:
php_value upload_max_filesize 50000000B // 50M
php_value post_max_size 50000000B // 50M
I have xenforo and yetishare. In both, when i try to upload files around 256 mb, the progrss bar starts, goes till 150mb + and then the progess bar again comes back to 0% and start uploading again. It does like 4 times then shows error that the file can't be uploaded.
I can upload a file, 126mb without any problem.
My Php Info : http://dl.godgivens.com/temp.php
I have set them temp directory of php to /tmp and uploaded a .htaccess file there with this settings, [these are the only lines in it]
LimitRequestBody 0
php_value upload_max_filesize 0
php_value post_max_size 4939212390
My file uploader, is index.php, and the .htaccess file also has the above settings as well as the folder which the files are saved also have the above settings.
You could see my php.ini settings, link i gave above.
IN httpd.conf under my httpd folder in /etc i have set timeout to 900.
I couldn't find limit request body anywhere.
In php.conf, i have added this to the last section,
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 0
</Files>
and i have added this line to fcgid.conf,
FcgidMaxRequestLen 1073741824
So it looks like,
# This is the Apache server configuration file for providing FastCGI support
# via mod_fcgid
#
# Documentation is available at http://fastcgi.coremail.cn/doc.htm
LoadModule fcgid_module modules/mod_fcgid.so
<IfModule mod_fcgid.c>
<IfModule !mod_fastcgi.c>
AddHandler fcgid-script fcg fcgi fpl
</IfModule>
FcgidIPCDir /var/run/mod_fcgid/sock
FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm
FcgidIdleTimeout 40
FcgidProcessLifeTime 30
FcgidMaxProcesses 20
FcgidMaxProcessesPerClass 8
FcgidMinProcessesPerClass 0
FcgidConnectTimeout 30
FcgidIOTimeout 45000
FcgidInitialEnv RAILS_ENV production
FcgidIdleScanInterval 10
FcgidMaxRequestLen 1073741824
</IfModule>
I have also added edited it, in domain configuration, nginxdomainvirtualhost.php.
Rebooted servers, reloaded httpd, restarted https, reconfigured things, but still it is just as same as before:/
I want to be able to upload 1gb-2gb files in my forum.
Here is the example of it uploading,
Please see the link below to see it uploading.
http://gyazo.com/c40cb03c503f172a3bc737d688f7cb00.gif
This is the one I followed : 4GB HTTP File Uploads Using jQuery-File-Upload, Apache and PHP
I thing this is because your hosting provider has given upload limit 126...
so you must ask your hosting provider to increase upload limit or you can use client side ftp upload script (flash/java) to handle file upload. But for client side ftp upload you need to modify your yetishare script
I have changed all the php.ini parameters I know:
upload_max_filesize, post_max_size.
Why am I still seeing 2MB?
Im using Zend Server CE, on a Ubuntu VirtualBox over a Windows 7 host.
Find the file called: php.ini on your server and follow below steps
With apache2 and php5 installed you need to make three changes in the php.ini file. First open the file for editing, e.g.:
sudo gedit /etc/php5/apache2/php.ini
OR
sudo gedit /etc/php/7.0/apache2/php.ini
Next, search for the post_max_size entry, and enter a larger number than the size of your database (15M in this case), for example:
post_max_size = 25M
Next edit the entry for memory_limit and give it a larger value than the one given to post_max_size.
Then ensure the value of upload_max_filesize is smaller than post_max_size.
The order from biggest to smallest should be:
memory_limit
post_max_size
upload_max_filesize
After saving the file, restart apache (e.g. sudo /etc/init.d/apache2 restart) and you are set.
Don't forget to Restart Apache Services for changes to be applied.
You probably didn't restart your server ;)
Or you modified the wrong php.ini.
Or you actually managed to do both ^^
Just change your php.ini(xampp/php/php.ini) file, it worked for me!
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M
post_max_size = 750M
upload_max_filesize = 750M
And, don't forget to restart Apache Module from XAMPP Control Panel.
Increase phpMyAdmin upload / import size
By default you get a 2mb limit of upload / import size in phpmyadmin. That makes it odd and highly impossible to import larger files. You can increase the allowed upload size of phpmyadmin by editing your server’s php.ini configuration file. Usually in servers like CentOs it is located at /etc/php.ini.
Step 1: Go to php.ini and find the following and change their values to something more higher than your database size. (In this example i have used 20mb).
upload_max_filesize = 20M
post_max_size = 20M
Step2 : Restart your apache service for this new change to take effect. Usually the command to restart apache would be
service httpd restart (CentOs) / service apache2 restart (ubuntu)
You can also restart directly from their path like
/etc/init.d/apache2 restart or /etc/init.d/httpd restart
If you are in a shared hosting and do not have root access or access to your php.ini configuration file, then the other way is to create a .htaccess file in your application root and add the following line
php_value upload_max_filesize 10M
php_value post_max_size 10M
If you were still not able to increase it, please send me an email for more detailed assistance.
For uploading large files through PHPMyAdmin, follow these steps:
Step 1: Open your php.ini file.
Step 2: Upgrading Memory Limit:
memory_limit = 750M
Step 3: Upgrading Maximum size to post:
post_max_size = 750M
Step 4: Upgrading Maximum file-size to upload:
upload_max_filesize = 1000M
Step 5: Upgrading Maximum Execution Time:
max_execution_time = 5000
Step 6: Upgrading Maximum Input Time:
max_input_time = 3000
Step 7: Restart your xampp control panel.
Check your all 3:
upload_max_filesize
memory_limit
post_max_size
in the php.ini configuration file
* for those, who are using wamp #windows, you can follow these steps: *
Also it can be adapted to any phpmyadmin installation.
Find your config.inc.php file for PhpMyAdmin configuration (for wamp it's here: C:\wamp\apps\phpmyadminVERSION\config.inc.php
add this line at the end of the file BEFORE "?>":
$cfg['UploadDir'] = 'C:\wamp\sql';
save
create folder at
C:\wamp\sql
copy your huge sql file there.
Restart server.
Go to your phpmyadmin import tab and you'll see a list of files uploaded to c:\wamp\sql folder.
With WAMP, on Windows10, open
c:\wamp64\alias\phpmyadmin.conf
and change 128 by 256 at the end of these lines
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
Restart WAMP
Open this file
edit these parameters:
memory_limit =128M
post_max_size = 64M
upload_max_filesize = 64M
This is how i did it:
Locate in the /etc/php5/apache2/php.ini
post_max_size = 8M
upload_max_filesize = 2M
Edit it as
post_max_size = 48M
upload_max_filesize = 42M
(Which is more then enough)
Restarted the apache:
sudo /etc/init.d/apache2 restart
None of the current answers will work for WHM / cPanel servers.
To increase the limit in WHM:
Navigate to Server Configuration > Tweak Settings
Choose the PHP tab
Update "cPanel PHP max POST size" & "cPanel PHP max upload size" (POST size should be bigger)
Ubuntu 20.04, 20.10, 22.04 and 22.10.
Well, with other distros as base Ubuntu as Xubuntu.
Edit : sudo nano /etc/php/7.4/apache2/php.ini
Search and modify : post_max_size = 120M and upload_max_filesize = 120M
Replace 120 with the value you need, e.g. 22M, etc.
Important, you have to change to the version of PHP that you have by default at that moment. Example with PHP 8.1: sudo nano /etc/php/8.1/apache2/php.ini
To check what version of PHP you have, just run php -v in your terminal.
I had the same problem.
My Solution:
go to /etc/phpmyadmin and edit apache.conf
in the <Directory>[...]</Directory> section you can add
php_value upload_max_filesize 10M
php_value post_max_size 10M
Solved the problem for me!
I found the problem and am post hete if anyone followed some blog post out there to create the sort of enviromment I have (win 7 host with ubuntu and zend server ce on virtual box).
The thing is that MySQL is running on Lighttpd, not under Apache. So I had to change the php.ini file under that webserver as well which is in the path:
/usr/local/zend/gui/lighttpd/etc/php-fcgi.ini
In the end, you were right about the files, of course, but I was wrong on what file I had to change :)
C:\xampp\php\php.ini in my case
or it could be C:\php\php.ini if the Apache / PHP / MySQL are stand alone
upload_max_filesize = 2M by default
so it can be changed as desired. And in my case
upload_max_filesize = 20M
post_max_size = 8M by default
it should be changed to post_max_size = 20M as well
memory_limit=128M is by default and it is not necessary to change to increase the max
2056kb or 2mb .sql file upload limit. But it only means that a script can consume up to 128 memory when you run apache and sql server , and if you change memory_limit=128M to higher and run any malfunctioned script then it may cause you trouble. So its up to you.
I had a problem with changing the upload size on my phpmyadmin and OS X 10.9.4 Mavericks.
At first I didn't know where the php.ini is so used locate
locate php.ini
which came back with
/private/etc/php.ini.default
/usr/local/etc/php/5.4/php.ini
I've tried editing /usr/local/etc/php/5.4/php.ini and then restart in the server put this didn't work.
I remembered that there is a better way to find out this file I'm looking for or and least where php is looking for php.ini.
<?php phpinfo() ?>
came back saying that it expects /etc/php.ini but I didn't have one there. The below is from the phpinfo():
Configuration File (php.ini) Path: /etc
It turns out that the first result in the locate command above is what I'm looking for.
At least in OS X 10.9.4 Mavericks (OS X is something new to me) /etc is actually a link, etc -> private/etc, and by the looks of it PHP assumes default values unless php.ini is actually present.
I copied /private/etc/php.ini.default
cp /private/etc/php.ini.default /private/etc/php.ini
Then checked the variables in the new /etc/php.ini as per Aditya Bhatt advice above and it worked.
In my case the values were:
memory_limit =128M
post_max_size = 64M
upload_max_filesize = 64M
Obviously, the apache service has to be restarted to see the changes.
php_value upload_max_filesize 100M
php_value post_max_size 100M
increse that size in php.ini then run command
sudo service apache2 restart
sudo service mysql restart
in xammp
restart all service
How to import huge amount of Data in Xampp
It’s the best solution to open new, clean database, and import the file in phpMyAdmin. Choose file from local folder and leave all settings as is. That should be it.
But if your file exceeded file size of 2MB (that is default value in xampp installation) than you need to tweak some out. Basically we will just increase the maximum upload file size.
Open your xampp install folder and go to php folder. With some text editor file (notepad++) open the file called php.ini (by type windows describe it as configuration settings) and edit the line (cca. 770, or press ctrl+f in notepad++ to find it):
post_max_size = 2M
instead 2M, put wanted maximum file size (16MB for example but not higher than 128M),
after that go to this line:
max_execution_time = 30
instead 30, increase execution time that’s in seconds (90 for example), also you need to change this line:
max_input_time = 60
instead 60, increase input time in seconds (120 for example)
and top of all you have to change this line:
upload_max_filesize = 2M
instead of 2M, increase to 16M for example.
Save the file, restart apache and mysql in xampp and try to upload again, if you follow correctly you should be able to import files through 16MB (example)
You could just use MySQL administrator app or MySQL workbench.
Lightweight apps and you can export or import your entire server however the size.
Am late to the party here but I hope it helps someone.
I had the same problem, My upload limit was 2 MB, I edited my php.ini, and I set it to 5 MB but still it was showing 2 MB even after restarting server. Than I compressed my .sql file to zip by keeping its name as xyz.sql.zip so it became 451 kb from 3.5 mb. Then I uploaded it again. It worked for me.
I found that increasing the upload and post limit in php.ini did not affect the limit in phpmyadmin. This is because my server has a separate setting for cpanel upload limit. If you have access to WHM, you probably have this.
To adjust:
login to your WHM panel: this is usually located at {your server ip}/whm and you will need your root login details here. If you don't have those, request them from your host.
once logged in, in the top left search bar, search for "tweak settings"
On the tweak setting pages, search for "cPanel PHP max upload size"
Adjust the number and save
No need to restart apache or anything, changes are instant. This process increased the value of max upload file size in phpmyadmin. You can check this by going to phpmyadmin and selecting your database, then clicking "import" at the top. Beside the file selector you will see the upload limit. My server default was 100.
In my case, I also had to add the line "FcgidMaxRequestLen 1073741824" (without the quotes) in /etc/apache2/mods-available/fcgid.conf. It's documented here http://forum.ispsystem.com/en/showthread.php?p=6611 . Since mod_fcgid 2.3.6, they changed the default for FcgidMaxRequestLen from 1GB to 128K (see https://svn.apache.org/repos/asf/httpd/mod_fcgid/trunk/CHANGES-FCGID )
do the following things
increase upload_max_file_size in php.ini
gzip your sql file
and then import the file
I was facing the same problem where increasing max size in php.ini has no effect on wordpress and tried many solutions like -:
Increase max size via functions.php
Increase max size via .htaccess file.
The one that worked for me is adding max size in .htaccess file.
It wasn't working with neither with php.ini file nor with functions.php file.
I just did add this code in .htaccess file and its done
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
NOTE: I did add above code in <IfModule> tag.
If php.ini file is not doing anything in changing size then try other 2 files for it and one of them will surely work for you.
READ THIS ARTICLE TO KNOW ABOUT ALL FILES IN WHICH YOU CAN INCREASE MAX SIZE
I think if your php version is above 5.5, let say it is 5.6, then your php.ini file is in following folder
/etc/php/5.6/apache2
so you have to apply your changes like post_max_size, upload_max_filesize and memory_limit there.
Hope it will help you.
I've tried all of the above and nothing worked for me: my phpmyadmin (on wamp) was still showing 128MiB (while I've needed to import DB which size was 212Mb)
so if U stucked as me you can import it with the help of commandline:
run bash (cmd, powershell or whatever terminal) from folder where your .sql file is located (or cd that path in terminal)
run mysql -u username -p database_name < file.sql where
username - is username for mysql server
database_name - is name of db you want import to
file.sql - is name of your sql file
👍😉
for me just worked like a charm after 2hours of trying to manipulate this through php.ini and other configurational files 🙈👌
Search for php.ini file
For xampp, you can get it # C:\xampp\php
Find the following 3 properties and set there value according to your need
memory_limit
post_max_size
upload_max_filesize
Restart Apache!
I am using Bitnami WAMP Stack 7.1.8-0 on my localhost. For me, the PHPMyAdmin maximum upload size limit was set to 80MiB as in the screenshot https://nimb.ws/fFxv7O. I managed to increase this size limit as explained below:
Go to the folder where you have installed the Bitname WAMP Stack, for me, it is "E:\Bitnami WAMP Stack”
Further inside, go to the path “apps\phpmyadmin\conf"
Open the file httpd-app.conf in your favorite text editor
Find the following two lines:
php_value upload_max_filesize 80M
php_value post_max_size 80M
(The 80M value at the end of these lines may be different for you)
Go ahead and change these values at the end of these two lines (80M in this case) according to your needs.
Restart WAMP server.
Now go to PHPMyAdmin and see, your upload size limit should be updated to whatever you set it to. That is it.
Note: (added July 2020)
I'm surprised nobody else has mentioned this ... changing php.ini should probably be your last resort when increasing file upload sizes to something as big as 64MB.
It may not matter greatly on development machines, but editing php.ini to globally increase max upload size could be a really bad idea on a server where you have several websites operating. MySQL imports to PHPMyAdmin are often large, but you don't want every Tom, Dick and Mary uploading 64MB files to another site on your server because you need to do it every now and again for your MySQL database.
I'd suggest a better solution is therefore (assuming you are using the standard Apache PHP module) to edit the specific virtual host configuration for PHPMyAdmin.
On Ubuntu Linux, this is found in /etc/apache2/conf-enabled/
phpmyadmin.conf. On WAMP/Windows/Whatever you'll need to look at the setup for your Apache configuration, but it will probably be in conf-enabled, conf.d, sites-enabled, or something like that. These are actually often just symlinks to the actual file which is located somewhere like /etc/phpmyadmin/apache.conf (again using Ubuntu as the example here).
Your apache.conf file will include lines something like this:
Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options SymLinksIfOwnerMatch
DirectoryIndex index.php
# limit libapache2-mod-php to files and directories necessary by pma
<IfModule mod_php7.c>
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/:/usr/share/php/PhpMyAdmin/:/usr/share/php/Symfony/:/usr/share/php/Twig/:/usr/share/php/Twig-Extensions/:/usr/share/php/ReCaptcha/:/usr/share/php/Psr/Container/:/usr/share/php/Psr/Cache/:/usr/share/php/Psr/Log/:/usr/share/php/Psr/SimpleCache/
</IfModule>
</Directory>
Immediately after <IfModule mod_php7.c> add these lines:
php_value post_max_size 64M
php_value upload_max_filesize 64M
Depending on your server config, you can probably achieve the same thing in an .htaccess file if you prefer. In which case you could just add the two lines by themselves (assuming you know for certain that PHP is enabled).
If you use fpm or fastcgi or something with or without Apache, the same more localized approach to controlling upload sizes can be achieved by using .user.ini files.
Ubuntu 20.04:
Changing php.ini files and restarting apache was not enough, I had to also do this:
sudo service php7.4-fpm restart
The first things to check (or ask your host provider to check) are the values of max_execution_time, upload_max_filesize, memory_limit and post_max_size in the php.ini configuration file. All of these three settings limit the maximum size of data that can be submitted and handled by PHP.
Please note that post_max_size needs to be larger than upload_max_filesize.