我的问题是我想只显示主页上传的多张图片中的一张图片,并在另一页上显示所有图片。
代码的第一部分用于完美的多重上传,代码的第二部分用于选择。但图像没有显示。
$file_name_all="";
for($i=0; $i<count($_FILES['image']['name']); $i++)
{
$tmpFilePath = $_FILES['image']['tmp_name'][$i];
if ($tmpFilePath != "")
{
$path = "upload/"; // create folder
$imagename = $_FILES['image']['name'][$i];
$size = $_FILES['image']['size'][$i];
list($txt, $ext) = explode(".", $imagename);
$file= time().substr(str_replace(" ", "_", $txt), 0);
$info = pathinfo($file);
$filename = $file.".".$ext;
if(move_uploaded_file($_FILES['image']['tmp_name'][$i], $path.$filename))
{
$file_name_all.=$filename."*";
}
$file="upload/" . $filename ;
}
}
$stmt = $this->conn->prepare('INSERT INTO help(name, email, phone, category, region, image, question, title, date)VALUES(:uname, :uemail, :uphone, :ucategory, :uregion, :uimage, :uquestion, :utitle, :udate)');
$stmt->bindParam(':uname', $name);
$stmt->bindParam(':utitle', $title);
$stmt->bindParam(':uemail', $email);
$stmt->bindParam(':uphone', $phone);
$stmt->bindParam(':ucategory', $category);
$stmt->bindParam(':uregion', $region);
$stmt->bindParam(':uimage', $file);
selection code.
public function needhelp(){
try{
$stmt = "SELECT help_id, name, image, question, date FROM help ORDER BY help_id DESC";
$result = $this->conn->query($stmt);
$result->execute();
return $row = $result->fetchAll();
}
catch(PDOException $e){
echo "query error" . $e->getMessage();
}
}