PHP BASE64到图像转换
base64是jpeg格式的。下面是我给出的PHP:PHP BASE64到图像转换,php,Php,base64是jpeg格式的。下面是我给出的PHP: $img['img'] = 'img1.png'; $filedata = explode(',', $this->input->post('lostimage1')); write_file('./uploads/'.$data['pet_hidenum'].'/'.$img['img'], $filedata[1]); 如何确定给定的base64是jpeg格式还是png格式?我的代码工作正常,但我只想知道base64字符串是
$img['img'] = 'img1.png';
$filedata = explode(',', $this->input->post('lostimage1'));
write_file('./uploads/'.$data['pet_hidenum'].'/'.$img['img'], $filedata[1]);
如何确定给定的base64是jpeg格式还是png格式?我的代码工作正常,但我只想知道base64字符串是jpeg或png
$imagedata = base64_decode("****");
$file = finfo_open();
$mime_type = finfo_buffer($file, $imagedata, FINFO_MIME_TYPE);
请参阅此将base64代码传递到PHP的mime_content_type函数中
<?php
// Will retrun as image/jpg or image/png depending on the type
$fileType = mime_content_type("base64codegoeshere");
?>
请帮助我如何在CodeIgniter中运行mime\u content\u type函数