我想创建一个from来更改表中记录的图像。当我将图像加载到窗体中时,图像似乎在那里,但是文件选择器控件文本显示“未选择文件”。我在做什么错了?
<html>
<body>
<main>
<form name="EditForm" action="test-save-edit.php" method="POST" enctype="multipart/form-data">
<?php
$post_id = trim($_GET["id"]);
require_once "config.php";
try{
$sql1 = "select picture from images where post_id=:post_id";
if($stmt1 = $pdo->prepare($sql1)){
$stmt1->bindParam(":post_id", $post_id, PDO::PARAM_INT );
if($stmt1->execute()){
if($stmt1->rowCount() > 0){
$i = 0;
while($row1 = $stmt1->fetch()){
?>
<input type="file" name="image<?php echo ++$i ?>" value="<?php echo base64_encode($row1['picture']) ?>"/>
<?php
}
}
}
unset($stmt1);
}
} catch (Exception $e) {
var_dump($e->getMessage());
var_dump($e->getCode());
}
?>
<input type="submit" value="Next" />
</form>
</main>
</body>
</html>