我想通过HTTP提供图像,例如example.com/images.php?id=1234。但它受条件(登录,权限)等条件限制。如果条件为真,它会发送一个合适的标题数据体和图像数据。否则,将发送另一张图像的内容。
答案 0 :(得分:3)
if(<your conditions>) {
header("Content-Type: image/jpeg"); // or image/png, etc (depends on type)
readfile("/path/to/conditions-met.jpg");
exit;
} else {
header("Content-Type: image/jpeg"); // or image/png, etc
readfile("/path/to/conditions-failed.jpg");
exit;
}