1
我面临问题在laravel 5.5中耗尽的内存大小。 它的以前意味着5.4版本我的代码正在工作,但不是现在。 为此我增加了内存大小从php.ini文件memory_limit 1024M。但不工作。 基本上我转换Base64文件格式文件,然后存储到我的本地存储的PC或服务器。允许的内存大小134217728字节耗尽(试图分配62926848字节)
控制器代码
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 \元器件\调试\ Exception \ FatalErrorException“,
文件有多大? – ceejayoz
检查数学。我看到134 MB,而不是1024. – ficuscr
看看phpinfo输出并检查memory_limit是否已更改。 –