I have a Symfony 4 application where I upload files with a 2MB restriction, this restriction works, in a dev environment all works perfectly, the image is well uploaded, but in prod, I always have the same message :
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /var/www/html/asso.issoire-web.fr/vendor/symfony/debug/Exception/OutOfMemoryException.php on line 1
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36864 bytes) in /var/www/html/asso.issoire-web.fr/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 108
this line is the problem
$file->move($this->getParameter($path), $name);
it moves the image in my assets so that I recover it in the view, I modify the memory_limit = -1 in php.ini, and upload_max_filesize = 200M post_max_size = 200M
but still the same problem the image does not upload because of that, do you have a solution?
I specify that all this is on a VPS
UPDATE:
here is the code that is problematic in production
if($form->isSubmitted() && $form->isValid()) {
$path = 'upload_directory';
// Récupère les valeurs sous formes d'objet profil
$profil = $form->getData();
// Récupère l'image
$image = $profil->getImage();
// Récupère le fichier soumis
$file = $image->getFile();
// Crée un nom unique pour chaque image
$name = md5(uniqid()).'.'.$file->guessExtension();
// Déplace le fichier
$file->move($this->getParameter($path), $name);
// Donne le nom à l'image
$image->setName($name);
$user->setImage($name);
$profil->setUser($connectedUser);
$manager->persist($profil);
$manager->flush();
}