我有一个Symfony 4应用程序,在该应用程序中我上传了2MB的限制文件,此限制有效,在开发环境中都可以正常工作,图像上传良好,但是在产品中,我总是有相同的消息:
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
这条线是问题
$file->move($this->getParameter($path), $name);
它将图像移动到我的资产中,以便在视图中恢复它,在php.ini中修改memory_limit = -1,然后upload_max_filesize = 200M post_max_size = 200M
但仍然有同样的问题,图像因此无法上传,您有解决方案吗?
我指定所有这些都在VPS上
更新:
这是在生产中有问题的代码
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();
}
尝试打印phpinfo并检查这些变量是否实际更新。也可能是您的路径问题或代码错误。尝试检查文件夹的权限。它似乎始终不是内存问题。您可以在此处检查是否是您的编码风格,查询或导致此问题的任何其他情况致命错误:允许的134217728字节已用尽的内存大小(CodeIgniter + XML-RPC)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句