Uploading large files in laravel 8 - file-upload

I would like to upload a large file, not more than 300mb on size. I will upload the file into the database. I have added the upload button in my form. My issue is how can I make this possible considering there is a limit to upload files. I have successfully uploaded other files which are less than 2mb and it have successfully uploaded.kindly help o how to go about on this, I am using laravel 8

I am using xampp | windows 10 | Laravel 8
There are several methods to achieve this, you can pick as per your requirement.
Xampp Apache Configuration : XXX:\xampp\php\php.ini
Updating in .htaccess file :-
<IfModule php7_module>
php_flag display_errors On
php_value max_execution_time 999
php_value max_input_time 999
php_value max_input_vars 1000
php_value memory_limit 9999M
php_value post_max_size 9999M
php_value upload_max_filesize 9999M
</IfModule>
Creating php.ini in public folder so that we can override main configuration of php.
display_errors = On
max_execution_time = 999
max_input_time = 999
max_input_vars = 1000
memory_limit = 9999M
post_max_size = 9999M
session.save_path = "/var/cpanel/php/sessions/ea-php73"
upload_max_filesize = 9999M
zlib.output_compression = Off
After making changes make sure you always restart your server to see the effect of changes, Plus you can always view the changes by running
dd(phpinfo()); OR <?php echo phpinfo(); ?>

Related

Best practice apache and mysql configuration

I home somebody can help me with tips of optimization, thank you :-)
I have the following vps server:
6 CPU Cores
320 GB Storage SSD
16 GB RAM
Apache version 2.4.6
MariaDB version 5.5.60
Most load is between time 17.00 to 19.00 and there the server is slow and sometimes goes down.
The server has around 200 websites with mysql queries.
my apache httpd.conf configuration:
KeepAlive Off
KeepAliveTimeout 5
MaxKeepAliveRequests 200
HostnameLookups Off
#KeepAlive Off
<IfModule prefork.c>
StartServers 50
MinSpareServers 50
MaxSpareServers 100
ThreadsPerChild 200
MaxClients 250
MaxRequestsPerChild 2000
</IfModule>
and in 01-cgi.conf
<IfModule mpm_worker_module>
LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_event_module>
LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
LoadModule cgi_module modules/mod_cgi.so
MaxRequestWorkers 4000
ServerLimit 5000
</IfModule>
mariadb my.cnf
symbolic-links=0
innodb_file_per_table = 1
myisam_sort_buffer_size = 64M
read_rnd_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
sort_buffer_size = 512K
table_open_cache = 64
max_allowed_packet = 1M
key_buffer_size = 16M
max_connections = 500
connect_timeout=30
max_connect_errors=2000
log-slow-queries=/var/log/mariadb/mysql-slow.log
skip-name-resolve
query_cache_limit = 1M
query_cache_size = 256M
I tried load test with loader.io with following settings but it seems to reach about 180-185 clients and my server timeout
clients from 0-250 duration 1 min

Increasing Apache max connection numbers with ServerLimit

I would like to change the default max connection numbers in Apache as the number of processes is now
# ps -ef | grep apache2 | wc -l
152
I have read that I have to change ServerLimit, but I don't see that in apache config files.
# grep -r ServerLimit .
#
Where should I apply that?
UPDATE:
Regarding the MPM module, I see this in mods-available/mpm_prefork.conf:
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxRequestWorkers 150
MaxConnectionsPerChild 0
</IfModule>
Should I increase MaxRequestWorkers only? Or I have to define ServerLimit?
MPM configuration setting located in conf.modules.d/00-mpm.conf file. You can configure ServerLimit after LoadModule entry. You can refer httpd process always 256

how can I set download size unlimited in apache 2.4.9 on wampserver

in my web application which is CodeIgniter, users can download a lot o file. but there is a problem when download more than 25 MB.
how can I set download size unlimited in apache 2.4.9 on wampserver ?
Try these different settings in C:\wamp\bin\apache\apache2.4.9\bin\php.ini
Although it is safer to use the wampmanager menus like this
(leftclick)wampmanager->PHP->php.ini
Find:
post_max_size = 8M
upload_max_filesize = 2M
max_execution_time = 30
max_input_time = 60
memory_limit = 8M
Change to:
post_max_size = 750M
upload_max_filesize = 750M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M
Then restart wamp to take effect

How do get my Apache server to recognize php_value in my .htaccess file?

I'm receiving the following error in my log files from my .htaccess file:
.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration
I am attempting to move a site from another server to my local Aquia Dev Desktop environment. So when I load the database and code and I attempt to browse to the site. I get an Internal Server Error
In my my .htaccess file I have the follow settings being applied with php_value:
-php_value memory_limit 256M
-php_value memory_limit 512M
-php_value upload_max_filesize 192M
-php_value post_max_size 224M
-php_value session.cookie_lifetime 3600
-php_value session.gc_maxlifetime 3600
-php_value max_execution_time 2400
-php_value max_input_time 300
Seems like it cant recognize the php_value command. Any thoughts on how to fix this issue?

PHPMyAdmin max upload size will not change, wrong php.ini file

I have recently reinstalled my server this time with WAMP, previously I was using XAMPP.
In phpmyadmin the max upload size for database files is at 2,048kb.
I have changed the three variables in php.ini according to several forums and articles on the problem, restarted my server and it has no effect what so ever.
Is there some kind of environmental path variable etc that needs setting elsewhere?
What am I missing.
Put these in php.ini
upload_max_filesize = 10M
post_max_size = 10M
Or you can put these in .htaccess:
php_value upload_max_filesize 10M
php_value post_max_size 10M
Replace 10M with anything you want.
Extra: To find what php.ini is currently used, create a file in the web root, let's say info.php that contains <?php phpinfo();. Then access that file from your browser, and search for php.ini. This has to be done through the browser, from the command line you will see the php.ini used in cli.
When finished, restart Apache for the changes to take effect.
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 all 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. :)
The php.ini may not be the one you expect. Be sure to check phpinfo to see what config is being used and which parameters are active.
Another lead : If you use PHP FPM, you need to restart the fpm service after setting values in php.ini. On debian based systems :
service php7.3-fpm restart
We need to increase the maximum file size value in php.ini file,
By default, the upload_max_filesize is set to 2MB in XAMPP
To resolve this problem:
We need to locate where the php.ini file is. in Xampp, it is found in C:\xampp\php.
Open the php.ini file, search for “upload_max_filesize” and replace the 2M (meaning 2-Megabyte) to a higher value, say 50M.
change: upload_max_filesize =2M
to: upload_max_filesize =50M
Restart Apache for the change to take effect.
This drove me insane but I found that WAMPServer has a file in alias/phpmyadmin.conf that I needed to make the changes in.