rendered paste body $u_uftn = $_FILES['file']['tmp_name'];
$u_ufn = basename($_FILES['file']['name']);
$u_ufs = $_FILES['file']['size'];
$u_up = "uploads/";
$u_upd = $u_up . "full_" . $u_ufn;
$u_tup = $u_up . "thumb_" . $u_ufn;
$u_vft = array("jpg","jpeg","png","gif");
$u_mfs = 2621440; // 2mb
list($u_fn, $u_ext) = explode(".", $u_ufn);
$u_cext = strtolower($u_ext);
list($u_iw, $u_ih) = getimagesize($u_uftn);
if ($_POST['upload']) {
if (!in_array($u_cext, $u_vft)) {
$msg = "<font color='red'>The filetype was invalid!</font>";
} elseif ($u_ufs > $u_mfs) {
$msg = "<font color='red'>The file was too large!</font>";
} else {
if ($u_iw > 400) {
if ($u_cext == "jpeg" || $u_cext == "jpg") {
$u_ic = imagecreatefromjpeg($u_uftn);
} elseif ($u_cext == "png") {
$u_ic = imagecreatefrompng($u_uftn);
} elseif ($u_cext == "gif") {
$u_ic = imagecreatefromgif($u_uftn);
}
$u_niw = 400;
$u_nih = $u_ih / $u_iw * $u_niw;
$u_ip = $u_nih / 2;
$u_ictc = imagecreatetruecolor($u_niw, $u_nih / 2.5);
imagecopyresampled($u_ictc, $u_ic, 0, 0, 0, $u_ip, $u_niw, $u_nih, $u_iw, $u_ih);
if ($u_cext == "jpeg" || $u_cext == "jpg") {
imagejpeg($u_ictc, $u_tup, 100);
} elseif ($u_cext == "png") {
imagepng($u_ictc, $u_tup, 100);
} elseif ($u_cext == "gif") {
imagegif($u_ictc, $u_tup, 100);
}
imagedestroy($u_ic);
imagedestroy($u_ictc);
} else {
copy($u_uftn, $u_tup);
}
if (move_uploaded_file($u_uftn, $u_upd)) {
$msg = "Your file ($u_fn), was uploaded!<br />";
} else {
$msg = "<font color='red'>There was an error when uploading, try again.</font><br />";
}
}
}