显示来自数据库mysql、PHP的图像
我已经做了一个代码,你可以选择一个图像从你的计算机和上传到数据库。由于某种原因,在我上传后(正确上传到数据库中),显示的图像不是我上传的图像,而是一个小图像,表明它无法从数据库中获取图像。有人能帮我吗??代码如下: index.php:显示来自数据库mysql、PHP的图像,php,html,mysql,sql,Php,Html,Mysql,Sql,我已经做了一个代码,你可以选择一个图像从你的计算机和上传到数据库。由于某种原因,在我上传后(正确上传到数据库中),显示的图像不是我上传的图像,而是一个小图像,表明它无法从数据库中获取图像。有人能帮我吗??代码如下: index.php: <?php ob_start(); include_once('connect.php'); session_start(); ?> <html> <head> <title>Upload an imag
<?php
ob_start();
include_once('connect.php');
session_start();
?>
<html>
<head>
<title>Upload an image</title>
</head>
<body>
<form enctype="multipart/form-data" action="index.php" method="POST">
<input type="file" name="image">
<input type="submit" value="Upload">
</form>
<?php
//file properties
$file = $_FILES['image']['tmp_name'];
if(!isset($file)) {
echo 'Please select an image.';
}else{
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
if($image_size == false){
echo 'That is not an image';
}else{
if (!$insert = mysqli_query($con,"INSERT INTO uploading_image(name,image) VALUES('$image_name','$image')")){
echo 'Problem uploading image';
}else{
$lastid = mysqli_insert_id();
echo 'Image uploaded. <br>Your image:<br><img src="get.php? id='.$lastid.'">';
}
}
}
?>
</body>
</html>
上传图像
检查数据库中字段映像的数据类型。它应该是blob或longblob。替换以下代码
$find_image = mysqli_query($row = mysqli_fetch_array($image));
用这个
$find_image = mysqli_query($row = mysqli_fetch_assoc($image));
字段的类型是什么上传\u image.image
?$find\u image=mysqli\u query($row=mysqli\u fetch\u array($image))代码>-这行有点不对劲
$find_image = mysqli_query($row = mysqli_fetch_assoc($image));