我想显示存储在我的数据库中的图像,但我一直收到该错误。该图像以长印的形式存储在我的数据库中。我在上传时使用这段代码上传它.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();?>但是,当我转到/getImage.php?id= 1时,我有错误无法显示图像,因为它包含错误我做错了什么?
添加回答
举报
0/150
提交
取消