Home  >  Article  >  Backend Development  >  How to view pictures in php

How to view pictures in php

藏色散人
藏色散人Original
2019-10-09 09:31:424786browse

How to view pictures in php

How to view pictures in php?

Declare the read-write file as an image

How to view pictures in php

Open the image as a read-write file

How to view pictures in php

Adding b after r is suitable for binary files, and pictures also have better portability

How to view pictures in php

How to view pictures in php

##Read the picture closing handle

How to view pictures in php

Output picture content

How to view pictures in php

Because it is a picture, add header('content-type:image/jpeg ');

How to view pictures in php

The preview effect is as shown

Attached is the source code

<?php
header(&#39;content-type:image/jpeg&#39;);
 //读写图片
$filename=&#39;d.jpg&#39;;
$handle=fopen($filename,&#39;rb+&#39;); //读写二进制,图片的可移植性
$res=fread($handle,filesize($filename));
fclose($handle);
echo $res;

How to view pictures in php

Notes

No spaces before

##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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn