php二进制流文件

时间:2021-12-04 15:43:21
 <?php
 $img_file = 'test.png';
 // $fp = fopen($img_file, 'rb');
 // $content = fread($fp, filesize($img_file)); //二进制数据
 // fclose($fp);
 // header('Content-Type: image/jpeg');
 $content=file_get_contents($img_file); //二进制的流
 header('Content-Type: image/jpeg');
 echo $content;
 ?>