-2
データベースから画像を呼び出そうとしています。私は適切にデータベースに到達するイメージを確立しましたが、イメージを下に引っ張ると、それを構成するBLOBテキストが取得されます。画像を表示するには、どうすれば画像をプルダウンできますか?PHPデータベースから画像を取得するエラー
<?php
//libs
include 'library/config.php';
include 'library/opendb.php';
//query
$query = "SELECT * FROM `upload` WHERE `postID`=".$elem["postID"].";";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) > 0) { // if results exist
while ($row = mysqli_fetch_assoc($result)) { // assign db cont to variable
$name = $row["name"];
$size = $row["size"];
$type = $row["type"];
$content = $row["content"];
// header info
header("Content-length: $size");
header("Content-type: $type");
header("Content-Disposition: attachment; filename=$name");
//display image
echo "img", $content;
}
include 'library/closedb.php';
?>
あなたがMySQLでBLOBデータ型をしましたか? –
[MySQLデータベースから画像を取得してHTMLタグに表示する方法]の複製があります。(http://stackoverflow.com/questions/7793009/how-to-retrieve-images-from-mysql-database-and-display- in-an-html-tag) –
http://stackoverflow.com/questions/20556773/php-display-image-blob-from-mysqlの可能な複製 –