2013-12-20 74 views
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> 
+0

它被稱爲驗證。 http://www.smashingmagazine.com/2009/07/07/web-form-validation-best-practices-and-tutorials/ – Leeish

回答

相關問題