How to view pictures in php?
Declare the read-write file as an image
Open the image as a read-write file
Adding b after r is suitable for binary files, and pictures also have better portability
##Read the picture closing handle Output picture content Because it is a picture, add header('content-type:image/jpeg '); The preview effect is as shownAttached is the source code<?php header('content-type:image/jpeg'); //读写图片 $filename='d.jpg'; $handle=fopen($filename,'rb+'); //读写二进制,图片的可移植性 $res=fread($handle,filesize($filename)); fclose($handle); echo $res;
##header('content-type:image/jpeg');
For more PHP knowledge, please visit PHP Chinese website!
The above is the detailed content of How to view pictures in php. For more information, please follow other related articles on the PHP Chinese website!