Anastasia Robert
Anastasia Robert

Reputation: 1

symfony problem with ini_set() function when uploading big files

in a project created with symfony 4.4.* when uploading files i got the following error

Warning: POST Content-Length of 12406038 bytes exceeds the limit of 8388608 bytes in Unknown on line 0

I can fix this by changing the upload_max_filesize and post_max_size with the function ini_set()

my question is where to put it:

  1. just after the opning of the php tag of the controller.
  2. after the namespace .
  3. after the use's.

or in the specific method of the controller ?

Upvotes: -3

Views: 907

Answers (1)

Alexandre Tranchant
Alexandre Tranchant

Reputation: 4551

The best solution (a fact-based answer) is to set it in php.ini file to avoid any performance issue. And here is a useful chapter about configuration of ini variables.

But you cannot update these two parameters by using ini_set. Both of those options have the changeable mode of PHP_INI_PERDIR as CBroe mentionned it in his comment.

For other parameters, if you cannot update your php.ini, this question is likely to be answered with opinions rather than facts and citations. Depending on your web server, you can do it:

  • in a .php.ini file at the top directory of your project,
  • in a .ht_access in the public directory,
  • in the public/index.php file
  • in the Kernel.php

Upvotes: 0

Related Questions