如何使用PHP从源代码中隐藏图像路径
我想从网站中隐藏图像路径。首先,我做了以下几点:如何使用PHP从源代码中隐藏图像路径,php,Php,我想从网站中隐藏图像路径。首先,我做了以下几点: <?php // get image path $path = 'images/profiles/uploads/' . $list['thumbnail']; $type = pathinfo($path, PATHINFO_EXTENSION); $data = file_get_contents($path); $base64 = 'data:image/' . $type . ';base64,' . base64_encode($
<?php
// get image path
$path = 'images/profiles/uploads/' . $list['thumbnail'];
$type = pathinfo($path, PATHINFO_EXTENSION);
$data = file_get_contents($path);
$base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
?>
mypage.php
:
function setImgDownload($imagePath) {
$image = imagecreatefromjpeg($imagePath);
header('Content-Type: image/jpeg');
imagejpeg($image);
}
<?php include('download.php'); ?>
<img src="<?php setImgDownload('images/Chrysanthemum.jpg') ?>" width="300"/>
如何将函数保存在单独的页面中?尝试将mypage.php更改为
<?php
include('download.php');
echo "<img src='".setImgDownload('images/Chrysanthemum.jpg')."' width='300'/>"; // calling function inside php
?>
在这里,不是在php外部创建HTML元素,而是使用echo将其放在php内部,并在调用php函数时进行转义。这应该会给你你所需要的。如果有人想偷你的照片,他们不可能stopped@Dagon如果他想要钢铁般的形象,没问题,我只想隐藏服务器路径。你试过
return
吗function@zan我已经试过了,但没有成功。您想添加哪一个限制?您可以为图像视图创建脚本
<?php
include('download.php');
echo "<img src='".setImgDownload('images/Chrysanthemum.jpg')."' width='300'/>"; // calling function inside php
?>