[英]PHP BASE64 to Image convert
base64 is of jpeg. base64是jpeg。 below is my given PHP:
以下是我给定的PHP:
$img['img'] = 'img1.png';
$filedata = explode(',', $this->input->post('lostimage1'));
write_file('./uploads/'.$data['pet_hidenum'].'/'.$img['img'], $filedata[1]);
How can I determine whether given base64 is of jpeg or png? 如何确定给定的base64是jpeg还是png? My code is working fine but I just want to know base64 string is jpeg or png
我的代码工作正常,但我只想知道base64字符串是jpeg还是png
Pass the base64 code into PHP's mime_content_type function. 将base64代码传递到PHP的mime_content_type函数中。
<?php
// Will retrun as image/jpg or image/png depending on the type
$fileType = mime_content_type("base64codegoeshere");
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.