画像の生データが有効かどうかを検証したい。
以下は私のコードです:
private function __blobToImage($imagerawdata)
{
$imagedata = base64_decode($imagerawdata);
// Set the content type header - in this case image/jpeg
header('Content-Type: image/jpeg');
$path = WWW_ROOT . "commapp_images".'/';
$file = mktime().".png";
$filepath = $path.$file;
// Output the image
$image = imagecreatefromstring($imagedata);
ob_start();
imagejpeg($image, $filepath, 80);
ob_get_contents();
ob_end_clean();
return $file;
}
コードを使用しているときに、次のエラーが発生します
"Notice (8): imagecreatefromstring() [function.imagecreatefromstring]: gd-jpeg, libjpeg: recoverable error: Premature end of JPEG file"
私は解決策なしでここを襲ったので、誰かが私を助けてください。