相关疑难解决方法(0)

将Base64字符串转换为图像文件?

我试图将我的base64图像字符串转换为图像文件.这是我的Base64字符串:

http://pastebin.com/ENkTrGNG

使用以下代码将其转换为图像文件:

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,这里有什么不对吗?

php base64

132
推荐指数
5
解决办法
29万
查看次数

标签 统计

base64 ×1

php ×1