<?php
//This function will display your form
function form(){
echo "<form action='?act=upload' enctype='multipart/form-data' method='post'>"
."Select your file for upload: <input type='file' name='file' size='30'> "
."<input type='submit' value='Upload'>";
}
//This function will upload your file
function upload(){
//Let's collect all info into variables
$file = $_FILES['file']['name'];
$type = $_FILES['file']['type'];
$size = $_FILES['file']['size'];
$temp = $_FILES["file"]["tmp_name"];
//Let's set max file size to 2mb
$max_size = "2097152";
//Now set allowed file types
$allow_type_1 = "torrent";
//If file size is bigger than 2mb than let's display an error
if($size > 2097152){
die("File is to big!");
}
//Now file type check, if file is not right we will display an error
if($type == $allow_type_1 or $type == $allow_type_2 or $type == $allow_type_3 or $type == $allow_type_4){
//If everything is good then let's upload
move_uploaded_file($temp, "upload/$file");
echo "Download: <a href='http://yoursite.xxx/upload/$file'>http://yoursite.xxx/upload/$file</a>";
}else{
echo "Wrong file!";
}
}
switch($act){
default;
form();
break;
case "upload";
upload();
break;
}
?>