【发布时间】:2014-04-08 06:28:49
【问题描述】:
我想在 PHP 文件中显示来自我的 PostgreSQL 数据库的图像。 在尝试了很多不同的可能性之后,我并没有走得太远。 这是我的工作:
上传:
echo "<div>".
"<table border=\"1\" cellpadding=\"3\">".
"<form action=\"test2.php\" method=\"post\" enctype=\"multipart/form-data\">".
"<tr>".
"<td>".
"<input type=\"file\" name=\"file\" id=\"file\">".
"<input class=\"button\" type=\"submit\" name=\"submit\" value=\"Submit\">".
"<tr>".
"</tr>".
"</form>".
"</table>".
"</div>";
显示:
if(isset($_FILES['file'])) //file uploaded
{
$file_raw = file_get_contents($_FILES['file']['tmp_name']);
$file = pg_escape_bytea($file_raw);
//Here is Code to insert into Database but just to test, I try it directly:
header('Content-Type: image/png');
echo pg_unescape_bytea($file);
}
我已经在一个额外的文件等中有显示部分,但这些是您需要了解的基本信息。
我不会显示任何图像,只有浏览器中的这个“损坏的图像”图标。 这里有什么问题?我该如何解决这个问题? 谢谢!
【问题讨论】:
标签: php postgresql png bytearray