php隐藏图片真实路径的方法

这篇文章主要介绍了php隐藏图片真实路径的方法,具有一定借鉴价值,需要的朋友可以参考下。下面就和我一起来看看吧。

php隐藏图片的方法:首先创建一个test.php示例文件;然后输入内容为“php隐藏图片真实路径的方法”;接着创建test3.php文件;最后通过“@copy”隐藏图片即可。

php隐藏图片真实路径的方法

  • 该方法适用于所有品牌电脑。

php 隐藏图片地址

代码:

test.php

<img src="https://www.php.cn/test3.php?path=file/118812060.jpg"> 
<br>this is test!

test3.php

<?php
$path=$_GET["path"];
$cacheimgname=str_replace("/","_",$path);
$localimg="testimg/".$cacheimgname;
 
if ((file_exists($localimg)))
{
$httpurl=$localimg;
}
else
{
$httpurl="http://www.domain.com/".$path;
@copy($httpurl,$localimg);//缓存图片!
}
 
header("Location:$httpurl");
exit;
?>

实际地址为:testimg/file_118812060.jpg

以上就是php隐藏图片真实路径的方法的详细内容了,看完之后是否有所收获呢?如果想了解更多相关内容,欢迎来亿速云行业资讯!