0
我在做一个测试版的“视频上传网站”,但人们只需要按上传就可以上传任何东西,并且垃圾我的数据库和视频网站,我怎么才能让它只上传,如果有文件attchedphp form no file no upload
我的代码是:
<?php
mysql_connect("ip","username","password");
mysql_select_db("database");
if(isset($_POST['submit']))
{
$name = $_FILES['file']['name'];
$temp = $_FILES['file']['tmp_name'];
move_uploaded_file($temp,"uploaded/".$name);
$url = "http://www.mysite.dk/videoer/uploaded/$name";
mysql_query("INSERT INTO `videos` VALUE ('','$name','$url')");
}
?>
<html>
<head>
<title>Upload din video | Se videoer</title>
</head>
<body>
<a href="videoes.php">Videoer</a>
<form action="index.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" name="submit" value="Upload!" />
</form>
<?php
if(isset($_POST['submit']))
{
echo "<br />".$name." Er blevet uploadet";
}
?>
</body>
</html>
它被称为验证。 http://www.smashingmagazine.com/2009/07/07/web-form-validation-best-practices-and-tutorials/ – Leeish