【发布时间】:2017-03-15 08:09:06
【问题描述】:
如何将 Base 64 图像存储到我的数据库和服务器文件夹。以下代码用于将该图像保存到我的服务器文件夹中。但图像无法打开。
$data = $src;
$data = str_replace('data:image/png;base64,', '', $data);
$data = str_replace(' ', '+', $data);
$data = base64_decode($data);
$file = '../emailtest'.rand() . '.png';
$success = file_put_contents($file, $data);
$data = base64_decode($data);
$source_img = imagecreatefromstring($data);
$rotated_img = imagerotate($source_img, 90, 0);
$file = '../emailtest'. rand(). '.png';
$imageSave = imagejpeg($rotated_img, $file, 10);
imagedestroy($source_img);
【问题讨论】:
-
我想将 Base64 图像保存到我的服务器文件夹,并且需要将路径保存到我的数据库。
标签: javascript php html5-canvas