我們可以像這樣將 PHP 變量設置為 HTML 表單中的輸入值<input type="number" name="price" value="<?php echo $editprice;?>" >但這不適用于類型文件的輸入。我這樣試試<?php$sqlch15="SELECT image1 FROM pc where id=$idtoe";$resultch15= mysqli_query($db, $sqlch15);while ($row = mysqli_fetch_array($resultch15)){ $editimg1 = "<img src='images/" .$row['image1']."'>";} ?><input type="file" name="image1" value = "<?php echo $editimg1;?>">但它不起作用什么是我的錯誤幫助我。
2 回答

慕仙森
TA貢獻1827條經驗 獲得超8個贊
如果你按下那個按鈕,你會上傳一張圖片到服務器的 /tmp 文件夾(或另一個為此設計的文件夾)
您將創建一個名為 $_FILES['image'] 的數組變量
[_FILES] => Array
(
[image1] => Array
(
[name] => example.png
[type] => image/png
[tmp_name] => /tmp/phpq0JHjV // that is the upload folder
[error] => 0
[size] => 10847
)
)
所以唯一有點意義的就是填寫文件名
<input type="file" name="image1" value="<?=$_FILES['image']['name'];?>">
但正如我所說,這沒有多大意義,因為缺少有關客戶端上此文件路徑的信息。
- 2 回答
- 0 關注
- 172 瀏覽
添加回答
舉報
0/150
提交
取消