6
votes

I have set up upload_max_filesize and post_max_size to 32Mb in php.ini.

I am using Symfony2. I have created an entity that contains a file variable so that people can upload a file:

/**
 * @Assert\File(maxSize="3M")
 */
public $file;
  • When the file is smaller than 3Mb, the file is correctly uploaded.
  • When 3Mb the validator is working fine, displaying the normal error message "file is too big"
  • However, when file > 32Mb (post_max_size):

Fatal error: Allowed memory size of 150994944 bytes exhausted (tried to allocate 62353390 bytes) in /Applications/MAMP/htdocs/Symfony/vendor/symfony/src/Symfony/Component/HttpKernel/Profiler/Profiler.php on line 177

Is there a way to make the validator work when the file uploaded is higher than post_max_size? How is Symfony handling file uploads that are bigger than post_max_size?

1

1 Answers

12
votes

This is an issue about PHP, not Symfony. As you limit POST params size, your submit request does even not "reach" controller.

As post_max_size limit all POST params, including files, you should define post_max_size higher than upload_max_filesize.

So now, your question seems to be related to this one : How to gracefully handle files that exceed PHP's `post_max_size`?