Skip to content

PHP Upload Large File Bug

Sponsor: Using RabbitMQ or Azure Service Bus in your .NET systems? Well, you could just use their SDKs and roll your own serialization, routing, outbox, retries, and telemetry. I mean, seriously, how hard could it be?

Learn more about Software Architecture & Design.
Join thousands of developers getting weekly updates to increase your understanding of software architecture and design concepts.


After spending an hour trying to debug a strange issue with PHP & handling large (2GB+) file uploads, I figured I should post the resolution in case someone stumbles upon this post. Most people are aware that they need to set the the upload_max_filesize and post_max_size directives to handle large file uploads.  However, there is bug within PHP that does not handle files larger than 2GB, even when these directives are set to a higher value. Problem You have the PHP directives set properly to handle the a 2GB+ file size however the $_FILES[x][‘error’] will be set to 1 (UPLOAD_ERR_INI_SIZE), indicating that the file size exceeded the upload_max_size directive. Solution You must set the upload_max_filesize = 0 This will prevent the $_FILES[x][‘error’] from being set, however the $_FILES[x][‘size’] will now be an overflowed integer. Reference https://bugs.php.net/bug.php?id=44522 Notes This applies to PHP version 5.3.3.  Not tested with other/latest versions.