目前,我有下面的代碼,包含上傳表單爲什麼我的php腳本沒有在原始頁面中回顯結果?
<form enctype="multipart/form-data" action="uploader.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" />
Choose a file to upload: <input name="uploadedfile" type="file" /><br />
<input type="submit" value="Upload File" />
</form>
<? include('uploader.php'); ?>
我那麼有保存在同一目錄中的文件uploader.php的頁面。該文件包含以下代碼:
<?php
if($_POST){
// Where the file is going to be placed
$target_path = "uploads/";
/* Add the original filename to our target path.
Result is "uploads/filename.extension" */
$target_path = $target_path .time() .basename($_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The <a href=" . $target_path . ">file</a> has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
?>
我的目的是把它在同一頁上呼應"The <a href=" . $target_path . ">file</a> has been uploaded";
,而是將其重定向到另一個頁面,顯示此消息。
這是怎麼發生的?
它重定向對錶單操作使用 – 2016-04-26 09:40:26
謝謝,龍的頁面。我刪除了表單動作位,現在它工作。 –