我正在尝试上传飞机的图像,然后用户需要填写注册,机场和公司,然后上传它,问题是信息没有进入数据库,有什么建议吗?
<?php
include("connection.php");
?>
<html>
<body>
<form action="" method="post" enctype="multipart/form-data">
Matricula: <input type="text" name="registration" value=""/><br><br>
Aeroporto: <input type="text" name="airport" value=""/><br><br>
Companhia: <input type="text" name="company" value=""/><br><br>
Upload da foto: <input type="file" name="uploadfile" value=""/><br><br>
<input type="submit" name="submit" value="Submit"/>
</form>
<?php
if ($_POST['submit'])
{
$mat = $_POST["registration"];
$air = $_POST["airport"];
$comp = $_POST["company"];
$filename = $_FILES["uploadfile"]["name"];
$tempname = $_FILES["uploadfile"]["tmp_name"];
$folder = "fotos/".$filename;
move_uploaded_file($tempname, $folder);
if($mat!="" && $air!="" && $comp!="" && $filename!="")
{
$query = "INSERT INTO aviacao VALUES
('$mat','$air','$comp','$folder')";
$data = mysql_query($conn, $query);
if($data)
{
echo "Foto inserida na Base de Dados";
}
}
else
{
echo "Preencher todos os campos";
}
}
?>
</body>
</html>
数据库
1 matricula varchar(35)
2 aeroporto varchar(100)
3 companhia varchar(100)
4 foto varchar(100)(这里应该去到文件夹所在的路径 照片是beign存储的)