Mick
Mick

Reputation: 31959

Symfony2 validator not working when file is bigger than post_max_size

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;

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?

Upvotes: 6

Views: 5131

Answers (1)

AlterPHP
AlterPHP

Reputation: 12727

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`?

Upvotes: 12

Related Questions