This is file upload security. but the checking of the file size doesn't work can someone help me with my code?
and when does and error become more than 0?
$filename = $_FILES["userfile"]["name"];
$tempfile = $_FILES["userfile"]["tmp_name"];
$filetype = $_FILES["userfile"]["type"];
$filesize = $_FILES["userfile"]["size"];
$error = $_FILES["userfile"]["error"];
//VALID FILE TYPES
$vaildtypes = array("application/pdf", "video clip/avi");
$array_val = in_array($filetype, $vaildtypes);
if($error > 0)
die("Error.");
else{
if($filesize > 10000000){
die ("File too big!!!");
}
else{
if($filetype == $array_val){
move_uploaded_file($tempfile,"uploads/".$filename);
echo "Upload Complete";
}
else{
die ("FILE TYPE NOT ALOWED!");
}
}
}