PHP代碼不重定向用戶使用報頭到目標頁面()。
碼(upload.php的):
<?php
session_start();
$folder = 'upload';
if (!empty($_FILES))
{
// Set temporary name
$tmp = $_FILES['file']['tmp_name'];
// Set target path and file name
$target = $folder . '/' . $_FILES['file']['name'];
// Upload file to target folder
$status = move_uploaded_file($tmp, $target);
if ($status)
{
// Set session with txtfile name
$_SESSION['txtfile'] = $_FILES['file']['name'];
// Redirect user
header('Location: explorer.php');
}
}
?>
所需的功能:
獲取頭()合作,以重定向用戶explorer.php。是的,文件成功上傳沒有任何問題。但用戶繼續留在同一頁面(upload.php)。
爲$狀態真的嗎?如果是這樣你需要退出(); –
@SajunaFernando我在頭後添加了一個exit(),沒有任何成功。 – kexxcream
試試這個: 嘗試{ $ status = move_uploaded_file($ tmp,$ target); (Exception $ oException){ var_dump($ oException);死; } –