我正在使用php开发注册表单,我需要上传文件而不是上传
$firstname=$_REQUEST['firstname'];
$lastname=$_REQUEST['lastname'];
$username=$_REQUEST['username'];
$password=$_REQUEST['password'];
$email=$_REQUEST['email'];
$Image=basename($_FILES['file']['name']);
$Image=str_replace(' ','|',$Image);
if($firstname && $lastname && $username && $email)
{
require 'dbconnect.php';
$query="select * from members where email='$email'";
$result=mysql_query($query);
$exists=mysql_num_rows($result);
if($exists>0)
{
$message=array("message"=>"email already existed");
echo json_encode($message);
}
else
{
if($Image)
{
$Image=date("YmdHis").".jpg";
$target_path="userimages/".$Image;
move_uploaded_file($_FILES["file"]["tmp_name"],$target_path);
$query="INSERT INTO `members`
(`username`, `firstname`, `lastname`, `email`, `password`, `image`) VALUES
('$username', '$firstname', '$lastname', '$email', '$password', '$Image')";
}
else
{
$query="INSERT INTO `members` (`username`, `firstname`, `lastname`, `email`, `password`) VALUES
('$username', '$firstname', '$lastname', '$email', '$password')";
}
$result=mysql_query($query);
}
}
html代码是
<html>
<form action="register.php" method="post" enctype="multipart/form-data">
<div>firstname<input type="text" name="firstname"></div>
<div>lastname<input type="text" name="lastname"></div>
<div>username<input type="text" name="username"></div>
<div>password<input type="text" name="password"></div>
<div>email<input type="text" name="email"></div>
<div>image<input type="file" name="file"></div>
<div><input type="submit" name="submit"></div>
</form>
</html>
在这个我上传图片但它没有上传到服务器,也没有上传到数据库,在这种情况下被执行
请帮我