我有以下php文件,用于获取和显示读取数据库的图像
<?php
require_once('database.php');
$db = new Database();
$id = $_GET['id'];
$order = $_GET['order'];
// do some validation here to ensure id is safe
header('Content-type: image/jpeg');
echo pg_unescape_bytea($db->getImageById($id, $order));
?>
这个文件运行良好,但是下面是我如何使用它的
$img_binary = file_get_contents('http://example.com/helper/getImageById.php?id=' . $id . '&order=1', false);
$img_base64 = base64_encode($img_binary);
我试图找到一种方式,我将不再需要提供硬编码信息,如
example.com
,我希望能够将所有文件移动到另一个服务器和/或域名,而不必更改服务器IP。这是一个将由多个域名使用的脚本。
如何才能做到这一点?