gpt4 book ai didi

php - 通过 PHP 加载图像

转载 作者:可可西里 更新时间:2023-11-01 13:34:29 24 4
gpt4 key购买 nike

我正在尝试通过 PHP 加载图像,但我不知道如何加载。文件名保存在数据库中,如image.jpg

if($_GET['image']){
// Client requesting image, so retrieve it from DB
$id = mysql_real_escape_string($_GET['image']);
$sql = "SELECT * FROM $tbl_name WHERE id = '$id' LIMIT 1";
}

客户端需要这样请求一张图片

http://example.com/index.php?image=1

然后它应该返回图像,所以它可以像这样嵌入:

<img src="http://example.com/index.php?image=1" alt="" />

这可能吗?

最佳答案

$img = 'path/to/image.jpg';
header('Content-Type: image/jpeg');
readfile($img);

刚刚测试过

关于php - 通过 PHP 加载图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9959131/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com