set_time_limit(3600);
if(isset($_FILES["filetoup"]))
{
$ext = pathinfo($_FILES["filetoup"]["name"], PATHINFO_EXTENSION);
$ok = 1;
// Check if file already exists
//if (file_exists($target_file)) {
// echo "Sorry, file already exists.";
// $ok = 0;
//}
// Check file size
if ($_FILES["filetoup"]["size"] > 1024000000) {
echo "Sorry, your file is too large.";
$ok = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($ok != 0)
{
$target_dir = "files/";
if(!file_exists($target_dir)) mkdir($target_dir,0777,true);
$name=$_FILES["filetoup"]["name"];
$target_file = $target_dir . basename($name);
if (move_uploaded_file($_FILES["filetoup"]["tmp_name"], $target_file)) {
$size=$_FILES["filetoup"]["size"]/1024;
echo 'File '.$name.' Has been uploaded.
';
} else {
echo "Sorry, there was an error uploading your file.";
}
}
}
else
{
echo '