我想顯示存儲在我的數(shù)據(jù)庫中的圖像,但我一直收到該錯誤。該圖像以長印的形式存儲在我的數(shù)據(jù)庫中。我在上傳時使用這段代碼上傳它.php:<body><form action="upload.php" method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name="image" /> <input type="submit" name="submit" value="UPLOAD" /></form><?phpif (isset($_POST["submit"])) { $check = getimagesize($_FILES["image"]["tmp_name"]); if ($check !== false) { $image = $_FILES['image']['tmp_name']; $imgContent = addslashes(file_get_contents($image)); /* * Insert image data into database */ //Insert image content into database $insert = $pdo->query("UPDATE users SET image='".$imgContent."'"."WHERE id_user = ".$posts[0]->get_id()); if ($insert) { echo "File uploaded successfully."; } else { echo "File upload failed, please try again."; } } else { echo "Please select an image file to upload."; }}?>然后我嘗試在獲取圖像中顯示它.php:<?php$id = $_GET['id'];$query = $pdo->prepare('SELECT * FROM users WHERE username LIKE :us');$query->bindValue(':us', $_SESSION['login'], PDO::PARAM_STR);$query->execute();$user = $query->fetchAll(PDO::FETCH_CLASS, "User");header ('Content-Type: image/png');echo $user[0]->get_image();?>但是,當(dāng)我轉(zhuǎn)到/getImage.php?id= 1時,我有錯誤無法顯示圖像,因為它包含錯誤我做錯了什么?
圖像無法顯示,因為它包含錯誤 (php)
墨色風(fēng)雨
2022-09-30 16:17:49