如何将带有扩展名的图像名称添加到超链接尾端php

如何将带有扩展名的图像名称添加到超链接尾端php,php,download,endpoint,Php,Download,Endpoint,我正在试图弄清楚如何使myimage.jpg成为超链接跟踪端点的一部分 到目前为止,我已经下载了图片,但不确定如何使超链接看起来像: http://192.168.0.11/myimage.jpg 到目前为止,我的代码是: <?php $file = "./my_image.jpg"; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type

我正在试图弄清楚如何使myimage.jpg成为超链接跟踪端点的一部分

到目前为止,我已经下载了图片,但不确定如何使超链接看起来像:

http://192.168.0.11/myimage.jpg
到目前为止,我的代码是:

<?php

$file = "./my_image.jpg";

if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="'.basename($file).'"');
    header('Expires: 0');
    header('Cache-Control: must-revalidate');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    readfile($file);
    exit;
}
?>

您可以使用
echo
在链接末尾打印
$file
变量

像这样,

<a href="//192.168.0.11/<?php echo $file; ?>">

非常感谢。但我不想传递到HTML。我想用Android中的Glide来消费这张图片。目前它确实获取图像并显示它。是的,我在下载时删除了标题,而不是显示它。当我查看HTML页面时,只是想看看它从PHP获得了什么样的输出。我得到:
<a href="//192.168.0.11/myimage.jpg">