我面临在 laravel 5.5 中耗尽内存大小的问题。它以前意味着我的代码是 5.4 版本,但现在不行。为此,我从 php.ini 文件 memory_limit 1024M 增加了内存大小。但不工作。基本上我正在转换 Base64 文件格式文件,然后存储到我的 PC 或服务器的本地存储中。
控制器代码
public static function convertBase64ToFile ( $file , $dir )
{
$pos = strpos($file, ';');
$type = explode(':', substr($file, 0, $pos))[1];
$format = explode('/',$type);
$exploded = explode(',', $file);
$decoded = base64_decode($exploded[1]);
if(str_contains($exploded[0], $format[1]))
{ $extension = $format[1];}
$filename = str_random().'.'.$extension;
$path = public_path().$dir.$filename;
file_put_contents($path, $decoded);
return $filename;
}
信息:
“允许的内存大小为 134217728 字节已用尽(试图分配 65015808 字节)”,“异常”:“Symfony\Component\Debug\Exception\FatalErrorException”,