Home > Backend Development > PHP Problem > How to view pictures in php

How to view pictures in php

藏色散人
Release: 2023-02-25 20:46:01
Original
4829 people have browsed it

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;
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template