我確定有一個簡單的解決方案,我無法看到。PHP成功上傳文件
我上傳的東西的一種形式。
當腳本完成時,在腳本的其餘部分運行之前,它使用Header('Location: admin.php?success')
和if($_GET['success']) { echo WOOHOO SUCCESS }
類型的消息。
的問題,這是你要上傳2個文件一次,你不能因爲腳本的第一部分是執行,沒有別的。然後我考慮使用布爾值來設置true或false,並顯示一條消息,但也失敗了。
我希望能夠上傳多個文件相繼並獲得成功的消息,爲每一個。
非常感謝。
相關PHP:
if(isset($_GET['success']) && empty($_GET['success'])){
echo '<h2>File Upload Successful! Whoop!</h2>';
} else{
if(empty($_POST) === false){
//check that a file has been uploaded
if(isset($_FILES['myTrainingFile']) && !empty($_FILES['myTrainingFile']['tmp_name'])){
file stuff...
if(in_array($fileExt, $blacklist) === true){
$errors[] = "File type not allowed";
}
}
if(empty($errors) === true){
//run update
move file stuff...
}
}
$comments = htmlentities(trim($_POST['comments']));
$category = htmlentities(trim($_POST['category']));
$training->uploadDocument($fileName, $category, $comments);
header('Location: admin.php?success');
exit();
} else if (empty($errors) === false) {
//header('Location: messageUser.php?msg=' .implode($errors));
echo '<p>' . implode('</p><p>', $errors) . '</p>';
}}
}
?>
表單在同一頁上?什麼是工作流程?選擇文件,點擊按鈕,然後會發生什麼...你能更加明確嗎? – Floris
在您的「成功」消息中,print_r($ _ FILES)並確保它們全部上傳。如果是,請嘗試類似foreach($ _ FILES AS $ k => $ v){echo'File'。$ k。'上傳!
'; } – Dylan
@floris - 是表單在同一頁上。如果不是生命可能來自用戶更容易:) 工作流 - 選擇相關的字段,請單擊 - 流量從「現場」(?) - 檢查網址是成功的,如果是打印的消息,如果沒有chekc表單,流程上傳] – null