在MySQL 資料庫中將影像作為二進位大物件(BLOB) 儲存和擷取是一種常見技術。然而,顯示這些圖像有時可能具有挑戰性。
解決方案
$query = "INSERT INTO products (image) VALUES(?)"; $stmt = $db->prepare($query); $stmt->bind_param('s', $image); $stmt->execute();使用PREPARED STATEMENT 將映像資料插入到變數的BLOB 欄位中資料庫:
$query = "插入產品(影像)值(?)"; $stmt = $db->準備($query); $stmt->bind_param('s', $image); $stmt->execute();
$query = "INSERT INTO products (image) VALUES(?)"; $stmt = $db->prepare($query); $stmt->bind_param('s', $image); $stmt->execute();使用PREPARED STATMENT 從資料庫擷取影像資料:
$query = "INSERT INTO products (image) VALUES(?)"; $stmt = $db->prepare($query); $stmt->bind_param('s', $image); $stmt->execute();使用base64_encode對圖像資料進行編碼並將其顯示為
免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3