Uploading large files in a dockerized Laravel app

Abdullahi Abdulkabir
2 min readDec 8, 2020

I was working on a project and requires upload of large files to the hosting server. At first I was a bit confuse whether I could just write a code to increase the upload time, execution time and all of that. Turns out that I need to modify the PHP.ini (PHP settings) in the docker settings since I was using php-alphine.

The first modification I did was to increase:

post_max_size: This is the limit of the entire body of the request, which could include multiple files. For more info on php site check here

upload_max_filesize: This set the upload maximum file size that can be uploaded. For more info on php site check here

max_execution_time: This set the max execution time. While uploading a large files this needs to be increased to avoid error like “Gateway timeout”

For my docker configuration, I had a custom-php.ini already setup. This file helps to override any configuration set in the php.ini file.

Above is a sample of how I set custom-php.ini in my docker and made some modification to the memory_limit, max_exexution_time etc.

When I build this image again, the changes will be effected on the php.ini file.

Note: It is not always advisable to edit php.ini file directly from the terminal, using the approach at the top seems the best.

Tadda!! We are done modifying the changes to allow large files upload.

I hope this helps, thanks for reading.

--

--

Abdullahi Abdulkabir

Muslim ||Systems Engineer|| Ex Software Engineer @montopolisgroup ||former facilitator @ Codelagos