二进制图片流转base64格式
<?php $file = 'C:/Users/Administrator/Pictures/1.png'; $imageInfo = getimagesize($file); $imageData = fread(fopen($file, 'r'), filesize($file)); $base64Image = 'data:' . $imageInfo['mime'] . ';base64,' . chunk_split(base64_encode($imageData)); echo $base64Image; ?>