标签:
<?php $file = "example.jpg"; $type = getimagesize( $file ); //取得图片的大小,类型等 $file_content = base64_encode( file_get_contents( $file ) ); switch ( $type[2] ) { //判读图片类型 case 1: $img_type = "gif"; break; case 2: $img_type = "jpg"; break; case 3: $img_type = "png"; break; } $img = ‘data:image/‘ . $img_type . ‘;base64,‘ . $file_content; //合成图片的base64编码 echo ‘<img src="‘ . $img . ‘" >‘; ?>
标签:
原文地址:http://www.cnblogs.com/icyy/p/4672294.html