我有下一个问题:验证姓名、地址和电子邮件的代码有效,但验证图像无效,不知道为什么会发生这种情况。一如既往地打印“选择图像”
我做了一个测试,并设置了用“print $photo”打印图像的临时名称但没有打印出来的行!
表单.php
<form id="formregister" name="formregister" action="register.php" method="post">
<input id="name" name="name" type="text"/>
<input id="address" name="address" type="text"/>
<input id="email" name="email" type="email" />
<input id="photouser" name="imguser" type="file"/>
<input id="bregister" name="bregister" type="submit" value="Registrer"/>
</form>
注册.php
..............
$name = $_POST['name'];
$address = $_POST['address'];
$email = $_POST['email'];
$photo = $_FILES['imguser']['tmp_name'];
$errors = array();
if(!isset($photo)) {
$errors[] = "Select an image";
} else {
$fototemp = addslashes(file_get_contents($_FILES['imguser']['tmp_name']));
$fotoname = addslashes($_FILES['imguser']['name']);
$fotosize = getimagesize($_FILES['imguser']['tmp_name']);
if ($fotosize == false) {
$errors[] = "Invalid format";
}
}
//Code to validate the other fields (name, address, email)
....................