($ data编码为jpg图像&然后通过以下代码对其进行解码&尝试将其存储在图像文件夹中)
$data = base64_decode($data); //decoded image
$im = imagecreatefromstring($data);
if ($im !== false)
{
header('Content-Type: image/jpg');
imagejpeg($im);
imagedestroy($im);
}
else
{
echo 'An error occurred.';
}
// storing it in image folder on
$success = file_put_contents('images/5.jpg',$im);
echo $success ? $im : 'Unable to save the file.';