读取图片路径,显示图片

这种方法相对来说比较安全,但是,需要再次查询数据库
首先要在b.html页面中加载一个php文件,比如a.php文件
此时在a.php文件中将图片路径读取出来,使用file_get_contents($path);
然后设置头,最后使用echo输出就可以了
a.php内容如下:

$path = $_GET['path'];
$img = file_get_contents($path);
header("Content-Type:img/jpg");
echo $img;

b.html内容如下:

<img src="./a.php?path=aaaa"/>

猜你喜欢

转载自blog.csdn.net/wuyoulv/article/details/77101699