我正在建立一个使用MySQL数据库的画廊(是的,我知道这是一个不好的做法,但它是当下的要求.)我可以上传多个图像,但我无法显示存储在数据库中的所有图像.FORM允许上传五张图片.然后,用户必须前进到另一个页面,其中数据库中的所有图像(包括最近上载的图像)将与图像的描述一起显示.我已经有代码但是在显示器上工作的代码不起作用或我认为是错误的.
这是表单代码:
<html>
<head>
<title> Upload image</title>
</head>
<body>
<div align="center">
<form action="fUpload.php" method="POST" enctype="multipart/form-data">
All forms must be filled. <br />
File: <br />
<input type="file" name="image[]"/> <input type="text" name="imageDescription[]" size="30" /> <br />
<input type="file" name="image[]"/> <input type="text" name="imageDescription[]" size="30" /> <br />
<input type="file" name="image[]"/> <input type="text" name="imageDescription[]" size="30" /> <br />
<input type="file" name="image[]"/> <input type="text" name="imageDescription[]" size="30" /> <br />
<input type="file" name="image[]"/> <input type="text" name="imageDescription[]" size="30" /> <br />
<input type="submit" value="Upload image" /> …Run Code Online (Sandbox Code Playgroud) 这是我上传的代码..但它不起作用..我使用了file_get_contents函数..上传图片
</head>
<body>
<form action="upload1.php" method="POST" enctype="multipart/form-data">
File:
<input type="file" name="image"/>
<input type="submit" value="Upload image" />
</form>
<?php
//connect to the database
$con = mysql_connect("localhost","root", "");
if(!$con)
{
die('Could not connect to the database:' . mysql_error());
echo "ERROR IN CONNECTION";
}
mysql_select_db("imagedatabase", $con);
//file properties
echo $file = $_FILES['image']['tmp_name'];
echo '<br />';
if(!isset($file))
echo "Please select an image";
else
{
$image = file_get_contents($_FILES['image']['tmp_name']);
echo $image_name = addslashes($_FILES['image']['name']); echo '<br \>';
echo $image_size = getimagesize($_FILES['image']['tmp_name']);
if($image_size == FALSE)
echo "That's not …Run Code Online (Sandbox Code Playgroud)