include("library2.php");
if( ($_GET['action']) && ($_GET['action']=="doUpload") )
{
$saveDir = $_SERVER['DOCUMENT_ROOT']."/vote/photos/";
$maxWidth = 400;
$maxHeight = 400;
$maxSize = 200; //in KB
$errors = Array();
$errors[0] = "Ooops, Looks like you forgot to select a file to upload, Try again.";
$errors[1] = "Sorry your photo is too large - it must be less than ".$maxSize."Kb";
$errors[2] = "Oops, we can only accept these file types GIF, JPG or PNG.";
$errors[3] = "Sorry.. the photo is too large. Please resize it to be less than $maxWidth x $maxHeight pixels.";
$errors[4] = "DOH, Your file didn't upload, the copying progress failed. Try again later.";
$imgCode = time();
$newFile = $imgCode.".".getFileExt($_FILES['photo']['name']);
$result = savePhoto($saveDir, $newFile, $maxWidth, $maxHeight, $maxSize);
if((int)$result < 5)
{
$errorStr = $errors[$result];
}
else {
$imgURL = "/vote/photos/".$result;
$new_id = addNewPhotoToVote($imgURL, $imgCode, $_POST['username'], $_POST['password'], $_POST['sex'], $_POST['age'], $_POST['emailAddress'], $_POST['region']);
sendEmail($_POST['username'], $_POST['emailAddress'], $imgCode, $_POST['password']);
setcookie("cw_lguser", $_POST['username'], time()+360000000);
setcookie("cw_icode", $imgCode, time()+360000000);
redirect("vote2.php?action=show&display=".getSex($_POST['sex'])."&img=$new_id");
die();
}
}
?>
Upload a Photo to HOT or NOT ~ ClubWizard.co.uk - London Nightlife Guide