您好我们计划允许我们的用户在同一页面上传封面照片和个人资料照片,但我们需要检测他们何时向我们提交文件。我们已经拥有的代码可以在下面看到。我们尝试了if(isset和if(存在但似乎没有做任何事情。
if($_POST['account_view'] === 'design') {
if (is_uploaded_file($_FILES['cover'])) {
if(isset($_FILES['cover']['name']) === true) {
if(empty($_FILES['cover']['name']) === true) {
$errors[] = 'Please select a file to use as your cover photo.';
} else {
$allowed = array('jpg', 'jpeg', 'gif', 'png');
$file_name = $_FILES['cover']['name'];
$file_extn = strtolower(end(explode('.', $file_name)));
$file_temp = $_FILES['cover']['tmp_name'];
if (in_array($file_extn, $allowed) === true) {
change_cover_image($session_user_id, $file_temp, $file_extn);
header("Location: $url/user/settings/?success&design");
} else {
$allowed_file_types_r = implode(', ', $allowed);
$errors[] = "You can\'t use this file type as your cover photo, but you can use these file types $allowed_file_types_r.";
}
}
}
}
if (is_uploaded_file($_FILES['profile']['name'])) {
if(isset($_FILES['profile']) === true) {
if(empty($_FILES['profile']['name']) === true) {
$errors[] = 'Please select a file to use as your profile photo.';
} else {
$allowed = array('jpg', 'jpeg', 'png');
$file_name = $_FILES['profile']['name'];
$file_extn = strtolower(end(explode('.', $file_name)));
$file_temp = $_FILES['profile']['tmp_name'];
if (in_array($file_extn, $allowed) === true) {
change_profile_image($session_user_id, $file_temp, $file_extn);
header("Location: $url/user/settings/?success&design");
} else {
$allowed_file_types_r = implode(', ', $allowed);
$errors[] = "You can\'t use this file type as your profile photo, but you can use these file types $allowed_file_types_r.";
}
}
}
}
}