每次选择图像后按下提交按钮都会遇到问题" 注意:未定义的索引:第5行的C:\ wamp \ www \ Test \ testImage.php中的profile_picture ",并且页面打印文本未选择,如果未选择图像,则必须显示该文本。 索引是定义的,但为什么它的行为如此,请帮助您的建议
<?php
$photo = "";
if($_SERVER['REQUEST_METHOD'] == "POST")
{
$photo = trim(stripslashes($_POST["profile_picture"]));
if($photo != '')
{
//$photo = trim(stripslashes($_POST["profile_picture"]));
header("Location: success.php");
}
else{
echo 'not selected';
}
}
?>
<!DOCTYPE html>
<html>
<body>
<form name="signup_form" method="post" action="<?php $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
<input type="file" class="profile_picture" id="profile_picture" name="profile_picture"> </br>
<input type="submit" name="submit_btn" id="submit_btn" class="submit_btn" value="sign up">
</form>
</body>
</html>