-1
我想在數據庫中插入圖像,但由於某些原因,我無法檢索它。我在數據庫中使用BLOB類型的圖像。PDO在數據庫中插入圖像並檢索圖像
我正在使用上傳圖片的代碼。有一次,我保存圖像數據庫,在「形象」專欄中,我得到我使用的打印網頁圖像文件圖像01.bin
if (isset($_POST["submit"]) {
$id= $_GET["id"];
$image = $_POST["image"];
$stmt=$conn->prepare("INSERT INTO db (id, image) VALUES (:id, :image)");
$stmt->bindParam(:id, $id);
$stmt->bindParam(:image, $image);
$stmt->execute();
}
代碼。
$stmt = "Select Id, Image from db where id = $id LIMIT 0,1"
$q = $conn->query($stmt);
while ($r = $q ->fetch():
echo "<img src ='",$r[Image],"' width='100' height='100' />";
endwhile;
二進制圖像數據是「in」$ _POST ['image']?可能的,但是......你是怎麼做到的? – VolkerK 2015-01-21 09:02:01
你必須閱讀的圖像內容把它放在一個blob ...看看http://stackoverflow.com/questions/23854070/pdo-insert-image-into-database-directly-always-inserting-blob-0b – 2015-01-21 09:02:01
'echo「」;'在這個php文件中加入適當的mime類型 – 2015-01-21 09:03:02