我确信有一个我看不到的简单解决方案。
我有一个上传东西的表格。
当脚本完成时,它会在脚本的其余部分运行之前使用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>';
}}
}
?>