我试图将我的base64图像字符串转换为图像文件.这是我的Base64字符串:
使用以下代码将其转换为图像文件:
function base64_to_jpeg( $base64_string, $output_file ) {
$ifp = fopen( $output_file, "wb" );
fwrite( $ifp, base64_decode( $base64_string) );
fclose( $ifp );
return( $output_file );
}
$image = base64_to_jpeg( $my_base64_string, 'tmp.jpg' );
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误invalid image
,这里有什么不对吗?