如何讓我非常簡單的視圖的html項目在表單的POST後重新出現?表單POST擦除視圖
我鋪陳HTML控制之下,則當用戶選擇 「上傳」提交按鈕,一個文件被上傳(成功),但所有 先前佈局的視圖元素消失。再次,該文件的上傳 工作正常。只是在index.php上顯示的html控件 在表單上傳並且瀏覽器窗口 爲空時消失。
如何在表單的POST後獲得非常簡單的視圖?
THIS IS的index.php:
<body>
<img src="/theWebsite/images/banner2.jpg" /img>
<br />
<input type="button" value="Play" onclick="showAnAlert(){}" />
// other buttons and text field html elements not shown
<form enctype="multipart/form-data" action="file-upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
</body>
這裏是文件upload.php的:
<?php
$target = "upload/";
$target = $target . basename($_FILES['uploaded']['name']) ;
$uploadingFile = $_FILES['uploaded']['tmp_name'] ;
if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
{
// I thought the problem was this 'echo' but the main view still goes blank after
// I commented this out here....
//echo "The file ". basename($_FILES['uploaded']['name']). " has been uploaded";
}
else {
// echo "errmsg"
}
?>
Shaka帥哥!那是我做的!唯一讓我誤解StackOverflow的是你只能'接受'一個答案 - 根據我的經驗,我發現自己從所有幫助過的人那裏學習 - 謝謝你們,我很樂意繼續這個。 – wantTheBest
@ wantTheBest:Michael有最完整的答案(我也贊成他)。 – NotMe