Hi Reader's,
Welcome to FindNerd,today we are going to discuss How to Upload Large Files in PHP?
Sometimes in a PHP web application. we need to upload a large file. So to manage large file upload in PHP web application we need to configure PHP.ini file and increase the memory limit, because at when we want to upload a large file which is greater than 2 Mega Bytes(MB), we have to increase memory limit for it with the help of PHP.ini file. This file is configuration file of PHP which is used for customizing the behaviour of PHP at runtime.
By default, PHP allows a maximum file upload of 2MB. So for uploading large images, we have to increase the limit. There are two PHP configuration options in which we can increase the limit according to our need.
1- upload_max_filesize = 24M
2- post_max_size = 32M
For getting the location of the php.ini file in your web application we have to call a phpinfo() function in our code.
you can see below example
<?php
// Show all information
phpinfo();
?>
By this function, we can also get the current values for the following settings which we need to modify for increasing the limit during file upload.
We can edit our PHP.ini file to handle large file transfer/upload.
memory_limit = 32M
upload_max_filesize = 24M
post_max_size = 32M
0 Comment(s)