I am uploading files and having trouble finding an answer to this question. Some of the time my file upload fails at move_uploaded_file() so I was told this could be a memory problem. Unfortunately there is no documentation available that I could find to answer this question.
The file I am uploading is 400mb and I set upload_max_filesize and post_max_size to 500mb. The max_execution_time and max_input_time are set to 60000 for testing purposes. My memory_limit is set to default 128mb. Should this be changed? How can you calculate the optimal balance of memory_limit vs upload_max_filesize and post_max_size for say a 400mb file?
If the upload fails, you shouldn’t even be attempting to do a move_uploaded_file. The proper bare-bones upload handling method is
The error codes are detailed here, and will tell you if the file was too large to handle due to PHP settings.
As for the PHP settings themselves. Your
post_max_sizeshould be the largest allowable file size, plus whatever other data you’re submitting alongside the file upload. memory_limit must be larger than the max file size, plus extra to allow for script overhead. PHP’s execution time limits do not come into play for uploads, as the script timers are not started until AFTER the upload is completed.