-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) –
Possibel重複http://stackoverflow.com/questions/20556773/php-display-image-blob-from-mysql –