Upload Large File by PHP - php

Here is my phpinfo()
https://devmail.equidesk.com/phpinfo.php
I can't upload more than 2MB file by php.
I increased upload limit in php.ini but it's not working.

see this:
Change the maximum upload file size
you should change php.ini
upload_max_filesize = 10M
post_max_size = 10M
And if you use nginx, should change nginx.conf file
like this.
server {
client_max_body_size 10M;
//other lines...
}
If you changed server configurations, you should restart fpm and nginx.
sudo service nginx restart
sudo service php5-fpm restart

Value of your upload_max_filesize attribute is 2M. Thats why you are unable to upload more than 2M.
You need to increase size of upload_max_filesize in php.ini file. After that you will be able to upload large file.
You can change it to 128M or 256M whatever you want depends upon size of your upload file.

upload_max_filesize in phpinfo still showing 2M
Change this and restart server
post_max_size = 250M
upload_max_filesize = 250M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M

Related

aws ubuntu instance php maximum file upload not changing

I am using aws instance for my file uploading functionality ( ubuntu php 7.0)
when printing phpinfo(), it shows upload_max_filesize as 2M.
I need to upload larger images upto 10 MB.
I have changed lines in php.ini files with upload_max_filesize to 30M which is found in the folder /etc/php/7.0/apache2/php.ini. and /etc/php/7.0/cli/
no effect and restarted the server with ssudo /etc/init.d/apache2 restart
There is no effect in the phpinfo result.
I created a php.ini and put it in the root folder with the lines
upload_max_filesize = 960M
post_max_size = 960M
and tried uploading lager files , it is not working
Then I have created .htaccess with the lines
php_value memory_limit 30M
php_value post_max_size 100M
php_value upload_max_filesize 30M
and tried lines in the PHP uploading script
ini_set('post_max_size', '64M');
ini_set('upload_max_filesize', '64M');
The above actions do not help me in larger files, please help. me.
Have you restarted your web server after making changes ?
You need to Change these two things "post_max_size, upload_max_filesize" in /etc/php/7.0/apache2/php.ini then definitely it will work.

echo $_FILES['data-file']['tmp_name']; die; file name is not printed if size more then 128M in PHP

I try to upload file of 300 MB. but not uploaded and now display any error.
variables value in php.ini file is
post_max_size 800M
upload_max_filesize 750M
memory_limit 2048M
max_execution_time 17100
max_input_time 17100
if i try to print tmp name of file by echo $_FILES['data-file']['tmp_name']; die; Nothing display page redirecto to home. but for less then 128M it show /tmp/phpShle like that.
If you are on LAMP make sure you are editing right php.ini file. In LAMP you will find cli related php.ini and php-apache related php.ini. To make above scenarios of file upload possible, you will need to edit php-apache php.ini file which is in /etc/php5/apache2/ and also restart apache service.
If you are on WAMP, it has only one php.ini and WAMP is automatically restarting services after editing file. So it should work.
-Or-
You can write a .htaccess file in web home directory.
RewriteEngine on
php_value post_max_size 300M
php_value upload_max_filesize 300M
Please write this on .htaccess.
<IfModule mod_php5.c>
php_value post_max_size 256M
php_value upload_max_filesize 256M
php_value memory_limit 500M
</IfModule>
This might help you. Cheers :)
My proble is solved. I need to set these variable on modsec2.user.conf file
SecRequestBodyLimit 1073741824
SecRequestBodyNoFilesLimit 1073741824
This is a apache server file. and error was shown on Apache error log.

How to Increase Import Size Limit in phpMyAdmin using Xampp server? [duplicate]

Does anyone know if or how you can increase the import size limit in phpMyAdmin? Currently my server is limited to 50MB.
Please note that this is not the same as the upload_max_filesize in php.ini. That value is set to 2MB.
I need to import a table into one of my DBs and the phpMyAdmin restriction of 50MB on the import is preventing me from doing that.
Thanks.
Amended -- attached are 2 screen shots:
Screen Shot #1 -- phpinfo() showing the php.ini settings.
Screen Shot #2 -- showing the phpMyAdmin import restriction
If you are using WHM/Cpanel then in order to change that "Max: 50MiB" limit in the import section of phpmyadmin, you will have to change two values in WHM (Web Host Manager).
Step 1) Go to Tweak settings, find the "cPanel PHP Max upload size" change it according to your needs. Save changes.
Step 2) Go to Tweak settings, find the "cPanel PHP Max POST size" change it according to your needs. Save changes.
Go back to your phpMyadmin. The value should have changed.
I had the same problem with my working correctly by doing the following
changes into the php.ini file
post_max_size = 800M
upload_max_filesize = 800M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M
now restart for the changes to take effect
Could you also increase post_max_size and see if it helps?
Uploading a file through an HTML form makes the upload treated like any other form element content, that's why increasing post_max_size should be required too.
Update : the final solution involved the command-line:
To export only 1 table you would do
mysqldump -u user_name -p your_password your_database_name your_table_name > dump_file.sql
and to import :
mysql -u your_user -p your_database < dump_file.sql
'drop table your_tabe_name;' can also be added at the top of the import script if it's not already there, to ensure the table gets deleted before the script creates and fill it
Change these values in php.ini
post_max_size = 750M
upload_max_filesize = 750M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M
Then restart Wamp for the changes to take effect. It will take some time. If you get following error:
Script timeout passed if you want to finish import please resubmit same zip file and import will resume.
Then update the phpMyAdmin configuration, at phpMyAdmin\libraries\config.default.php
/**
* maximum execution time in seconds (0 for no limit)
*
* #global integer $cfg['ExecTimeLimit']
*/
$cfg['ExecTimeLimit'] = 0;
I had the same problem. My .sql file was 830 MB and the phpMyAdmin import size allowed was 50MB (just as shown in the screenshot). When I zipped the file to .zip its size became about 80 MB. Then I zipped it to bzip2 format, and I was amazed to see that the file size was compressed to just 12MB (from 830MB to 12MB!!!). As phpMyAdmin allows three compression types i.e. .zip , .gzip and .bzip2 , therefore I uploaded the compressed bzip2 file and viola.... it was imported to the database!!! So by using the right compression, I was able to import a 830MB .sql file into phpMyAdmin.
NOTE: phpMyAdmin import page clearly instructs that the compressed filename should be like filename.sql.bz2 . It should not be like filename.bz2 .
NOTE 2: You can compress your .sql file to bzip2 compressed file using 7-Zip software. cPanel also has an option to compress a file to bzip2 format.
First you have to change values in php.ini file as per your requirements.
post_max_size = 1024M
upload_max_filesize = 1024M
max_execution_time = 3600
max_input_time = 3600
memory_limit = 1024M
Note - Change these values carefully. These values will impact for all of your projects of that server.
Now, If above solutions are not working, kindly check your phpmyadmin.conf file.
If you are using WAMP so you can find the file in "C:\wamp64\alias".
You have to change below values.
Values already in file are -
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
Change above code to -
# php_admin_value upload_max_filesize 128M
# php_admin_value post_max_size 128M
# php_admin_value max_execution_time 360
# php_admin_value max_input_time 360
Now just restart your server, to work with changed values. :)
this is due to file size import limit in phpmyadmin, default is very low, so you should increase upload_max_filesize
you can change this in your php.ini, replaced with this
upload_max_filesize = 100M
You can increase the limit from php.ini file. If you are using windows, you will the get php.ini file from C:\xampp\php directory.
Now changes the following lines & set your limit
post_max_size = 128M
upload_max_filesize = 128M
max_execution_time = 2000
max_input_time = 3000
memory_limit = 256M
If you have direct root SSH access to the machine you will be able to change the settings in:
/usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini
Just change the line:
upload_max_filesize = 50M
if you're using xampp, find the php.ini (in xampp folder itself), go to line 735 and change the post_max_size to the value you wish.
ex: if you want to upgrade to 80MiB,
post_max_size = 80M
make sure to restart apache after changing the value.
That's it...
Change the file phpmyadmin.conf on c:/wamp64/alias/phpmyadmin.conf
php_admin_value upload_max_filesize 512M
php_admin_value post_max_size 512M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
It's very important you increase the time to 5000 or higher, Thus, the process will not stop when you are uploading a large file.
That works for me.
go to your cpanel and search "ini editor". You'll get "Multiphp INI Editor"
There you select your wordpress directory and put
upload_max_filesize = 256M
post_max_size = 256M
memory_limit = 256M
Be sure you are editing php.ini not php-development.ini or php-production.ini, php.ini file type is Configuration setting and when you edit it in editor it show .ini extension. You can find php.ini here: xampp/php/php
Then
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 900
max_input_time = 50000000
memory_limit = 256M
1:nano /etc/php5/apache2/php.ini
you can find your php.ini location by uploading a file called phpinfo.php with the following contents<?php phpinfo();?> and access it by visiting yourdomain.com/phpinfo.php ,you will see the results
2:change the desired value to upload_max_filesize and post_max_size
such as :
upload_max_filesize = 200M
post_max_size = 300M
then it will become 200M.
3:restart your apache
IF YOU ARE USING NGINX :
cd /etc/php/<PHP_VERSION>/fpm example => cd /etc/php/7.2/fpm
nano php.ini
post_max_size = 1024M
upload_max_filesize = 1024M
max_execution_time = 3600
max_input_time = 3600
memory_limit = 1024M
after saving php.ini file , restart fpm using :
systemctl restart php<PHP_VERSION>-fpm
example => systemctl restart php7.2-fpm
I increased the max file size by going to CPanel > Select PHP version > Switch to PHP Extensions and then scroll to the upload_max_filesize field (it will have a clickable link for the size - mine was set at 2MB) and I increased it to 256MB. Then click "Save".
You Can Search php.ini file in C:\xampp\htdocs
changes into the php.ini file
post_max_size = 805M
upload_max_filesize = 805M
max_execution_time = 5005
max_input_time = 5005
memory_limit = 1005M
After editing Please restart XAMPP
On newer version of cpanel: search ini
size' and edit it...then save[enter
Sharky's answer was spot on. The phpMyAdmin upload file size displayed is NOT managed by the php.ini settings, which you can see when you run a phpinfo.php containing:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
It is good practice to increase your php.ini settings for:
post_max_size
upload_max_filesize
max_execution_time
max_input_time
memory_limit
You may use the settings example that Sujiraj R shared. Once you have made all of the changes to both your php.ini AND in the"Tweak Settings" area of WHM, when you launch phpMyAdmin and go to the import screen, you will see the size you selected for "cPanel PHP max upload size" field.
There were a lot of good answers on this post, but you had to look back and forth to get the right answer. I hope that by encapsulating those previous answers in this post I have helped just a bit. All of the answers I refer to on this post were derived by others that posted here, so please do not credit me with any of the answers posted herein.
If you don't want to change the upload size limit, or for some reason can not change the upload size limit, compressing the database to a zip or tar.bz2 will really reduce the size of your database. In my case it went from 60MB which was >10MB over the limit, and compressed to a zip it was only 18MB!

uploading files greater than 8 mb in php

Warning: POST Content-Length of 11313557 bytes exceeds the limit of
8388608 bytes
I am getting this above warning. I searched around internet and I have also increased the the following limits in php.ini:
max_input_time = 600000;
max_execution_time = 60000000;
file_uploads = On;
upload_max_filesize = 1000M;
post_max_size = 1000M;
and also in mysql.ini file i have changed
max_allowed_packet = 100M;
but still I get the following warning. Files less than 8mb are easily uploaded but greater than 8mb pops up the above error message.
You need to set the value of upload_max_filesize and post_max_size in your php.ini :
; Maximum allowed size for uploaded files.
upload_max_filesize = 40M
; Must be greater than or equal to upload_max_filesize
post_max_size = 40M
And then you should stop your apache service and then start your apache.
In case of linux based systems
/opt/lampp/lampp stop
/opt/lampp/lampp start
In case of windows just stop and stop your apache or your xampp service.
Check the phpinfo page and see you have edited the correct configuration file. Loaded configuration file can be found in phpinfo page under Loaded Configuration File
Add as first line at your process file
set_time_limit(0);

Opencart - Can I import live data into localhost database [duplicate]

Does anyone know if or how you can increase the import size limit in phpMyAdmin? Currently my server is limited to 50MB.
Please note that this is not the same as the upload_max_filesize in php.ini. That value is set to 2MB.
I need to import a table into one of my DBs and the phpMyAdmin restriction of 50MB on the import is preventing me from doing that.
Thanks.
Amended -- attached are 2 screen shots:
Screen Shot #1 -- phpinfo() showing the php.ini settings.
Screen Shot #2 -- showing the phpMyAdmin import restriction
If you are using WHM/Cpanel then in order to change that "Max: 50MiB" limit in the import section of phpmyadmin, you will have to change two values in WHM (Web Host Manager).
Step 1) Go to Tweak settings, find the "cPanel PHP Max upload size" change it according to your needs. Save changes.
Step 2) Go to Tweak settings, find the "cPanel PHP Max POST size" change it according to your needs. Save changes.
Go back to your phpMyadmin. The value should have changed.
I had the same problem with my working correctly by doing the following
changes into the php.ini file
post_max_size = 800M
upload_max_filesize = 800M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M
now restart for the changes to take effect
Could you also increase post_max_size and see if it helps?
Uploading a file through an HTML form makes the upload treated like any other form element content, that's why increasing post_max_size should be required too.
Update : the final solution involved the command-line:
To export only 1 table you would do
mysqldump -u user_name -p your_password your_database_name your_table_name > dump_file.sql
and to import :
mysql -u your_user -p your_database < dump_file.sql
'drop table your_tabe_name;' can also be added at the top of the import script if it's not already there, to ensure the table gets deleted before the script creates and fill it
Change these values in php.ini
post_max_size = 750M
upload_max_filesize = 750M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M
Then restart Wamp for the changes to take effect. It will take some time. If you get following error:
Script timeout passed if you want to finish import please resubmit same zip file and import will resume.
Then update the phpMyAdmin configuration, at phpMyAdmin\libraries\config.default.php
/**
* maximum execution time in seconds (0 for no limit)
*
* #global integer $cfg['ExecTimeLimit']
*/
$cfg['ExecTimeLimit'] = 0;
I had the same problem. My .sql file was 830 MB and the phpMyAdmin import size allowed was 50MB (just as shown in the screenshot). When I zipped the file to .zip its size became about 80 MB. Then I zipped it to bzip2 format, and I was amazed to see that the file size was compressed to just 12MB (from 830MB to 12MB!!!). As phpMyAdmin allows three compression types i.e. .zip , .gzip and .bzip2 , therefore I uploaded the compressed bzip2 file and viola.... it was imported to the database!!! So by using the right compression, I was able to import a 830MB .sql file into phpMyAdmin.
NOTE: phpMyAdmin import page clearly instructs that the compressed filename should be like filename.sql.bz2 . It should not be like filename.bz2 .
NOTE 2: You can compress your .sql file to bzip2 compressed file using 7-Zip software. cPanel also has an option to compress a file to bzip2 format.
First you have to change values in php.ini file as per your requirements.
post_max_size = 1024M
upload_max_filesize = 1024M
max_execution_time = 3600
max_input_time = 3600
memory_limit = 1024M
Note - Change these values carefully. These values will impact for all of your projects of that server.
Now, If above solutions are not working, kindly check your phpmyadmin.conf file.
If you are using WAMP so you can find the file in "C:\wamp64\alias".
You have to change below values.
Values already in file are -
php_admin_value upload_max_filesize 128M
php_admin_value post_max_size 128M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
Change above code to -
# php_admin_value upload_max_filesize 128M
# php_admin_value post_max_size 128M
# php_admin_value max_execution_time 360
# php_admin_value max_input_time 360
Now just restart your server, to work with changed values. :)
this is due to file size import limit in phpmyadmin, default is very low, so you should increase upload_max_filesize
you can change this in your php.ini, replaced with this
upload_max_filesize = 100M
You can increase the limit from php.ini file. If you are using windows, you will the get php.ini file from C:\xampp\php directory.
Now changes the following lines & set your limit
post_max_size = 128M
upload_max_filesize = 128M
max_execution_time = 2000
max_input_time = 3000
memory_limit = 256M
If you have direct root SSH access to the machine you will be able to change the settings in:
/usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini
Just change the line:
upload_max_filesize = 50M
if you're using xampp, find the php.ini (in xampp folder itself), go to line 735 and change the post_max_size to the value you wish.
ex: if you want to upgrade to 80MiB,
post_max_size = 80M
make sure to restart apache after changing the value.
That's it...
Change the file phpmyadmin.conf on c:/wamp64/alias/phpmyadmin.conf
php_admin_value upload_max_filesize 512M
php_admin_value post_max_size 512M
php_admin_value max_execution_time 360
php_admin_value max_input_time 360
It's very important you increase the time to 5000 or higher, Thus, the process will not stop when you are uploading a large file.
That works for me.
go to your cpanel and search "ini editor". You'll get "Multiphp INI Editor"
There you select your wordpress directory and put
upload_max_filesize = 256M
post_max_size = 256M
memory_limit = 256M
Be sure you are editing php.ini not php-development.ini or php-production.ini, php.ini file type is Configuration setting and when you edit it in editor it show .ini extension. You can find php.ini here: xampp/php/php
Then
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 900
max_input_time = 50000000
memory_limit = 256M
1:nano /etc/php5/apache2/php.ini
you can find your php.ini location by uploading a file called phpinfo.php with the following contents<?php phpinfo();?> and access it by visiting yourdomain.com/phpinfo.php ,you will see the results
2:change the desired value to upload_max_filesize and post_max_size
such as :
upload_max_filesize = 200M
post_max_size = 300M
then it will become 200M.
3:restart your apache
IF YOU ARE USING NGINX :
cd /etc/php/<PHP_VERSION>/fpm example => cd /etc/php/7.2/fpm
nano php.ini
post_max_size = 1024M
upload_max_filesize = 1024M
max_execution_time = 3600
max_input_time = 3600
memory_limit = 1024M
after saving php.ini file , restart fpm using :
systemctl restart php<PHP_VERSION>-fpm
example => systemctl restart php7.2-fpm
I increased the max file size by going to CPanel > Select PHP version > Switch to PHP Extensions and then scroll to the upload_max_filesize field (it will have a clickable link for the size - mine was set at 2MB) and I increased it to 256MB. Then click "Save".
You Can Search php.ini file in C:\xampp\htdocs
changes into the php.ini file
post_max_size = 805M
upload_max_filesize = 805M
max_execution_time = 5005
max_input_time = 5005
memory_limit = 1005M
After editing Please restart XAMPP
On newer version of cpanel: search ini
size' and edit it...then save[enter
Sharky's answer was spot on. The phpMyAdmin upload file size displayed is NOT managed by the php.ini settings, which you can see when you run a phpinfo.php containing:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
It is good practice to increase your php.ini settings for:
post_max_size
upload_max_filesize
max_execution_time
max_input_time
memory_limit
You may use the settings example that Sujiraj R shared. Once you have made all of the changes to both your php.ini AND in the"Tweak Settings" area of WHM, when you launch phpMyAdmin and go to the import screen, you will see the size you selected for "cPanel PHP max upload size" field.
There were a lot of good answers on this post, but you had to look back and forth to get the right answer. I hope that by encapsulating those previous answers in this post I have helped just a bit. All of the answers I refer to on this post were derived by others that posted here, so please do not credit me with any of the answers posted herein.
If you don't want to change the upload size limit, or for some reason can not change the upload size limit, compressing the database to a zip or tar.bz2 will really reduce the size of your database. In my case it went from 60MB which was >10MB over the limit, and compressed to a zip it was only 18MB!

Categories