我有一个表单,我需要在其中附加图像文件并上传到数据库,我可以将其插入到数据库中。但是我无法从数据库中检索图像来显示它。如何从数据库中获取图像并显示?
form2.php:
<form action="insert2.php" method="GET" enctype="multipart/form-data">
<div class="container">
<div class="row">
<h2>3. Description of Item(s) </h2>
</div>
<div class="col-xs-12">
<div class="styled-input wide">
<textarea name="description" required /></textarea>
</div>
// this is the file attachment where it allows to select file from computer.
<div>
<label>Attachment:</label><input type='file' name='img' ><br>
</div>
</div>
</form>
插入2.php:
$con= mysqli_connect('127.0.0.1','root','');
if(!$con)
{
echo 'Not Connected To Server';
}
if(!mysqli_select_db($con,'satsform1'))
{
echo 'Database Not Selected';
}
$description = $_GET['description'];
$image = $_GET['img'];
//insert image to database.
$sql = "INSERT INTO handover (description,image)
VALUES ('$description','$image')";
if(!mysqli_query($con,$sql))
{
echo 'Not Submitted';
}
else
{
echo 'Submitted';
}
header("refresh:2; url=selection.php")
?>
杨__羊羊