5000000) { $tmpfile=$_FILES['upl']['tmp_name']; @unlink($_FILES['upl']['tmp_name']); $isgone=file_exists($tmpfile); echo '{"status":"Error: Image file size exceeds 5MB !","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}'; exit(); } $updir=dirname( __FILE__ ); $updir=$updir."/uploads/ctp/".$_SESSION["cp_userid"]; $imgurl="/mini-upload-form/uploads/ctp/".$_SESSION["cp_userid"]."/".$_FILES['upl']['name']; $ipath="/mini-upload-form/uploads/ctp/".$_SESSION["cp_userid"]; $imgpath=$updir."/".$_FILES['upl']['name']; $imgname=$_FILES['upl']['name']; $icount=0; $sqlnc="SELECT Count(`caption_this_pic`.`hcimagename`) AS `incount` FROM `caption_this_pic` WHERE `caption_this_pic`.`hcimagename` = '".$imgname."'"; $querync=mysql_query($sqlnc) or $em=$em.mysql_error(); $icount = mysql_result($querync,0); mysql_free_result($querync); if($icount > 0) { @unlink($_FILES['upl']['tmp_name']); echo '{"status":"Error: Duplicate Image Name","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":"", "img":"", "extension":"","hcid":""}'; exit(); } if(!is_dir($updir)) { if(!mkdir($updir,0777)){echo '{"status":"System Error: Please try again.","imgurl":"","iwidth":"","iheight":"","thecount":"","badurl":,"hcid":""}';exit();} } if(move_uploaded_file($_FILES['upl']['tmp_name'], $updir."/".$_FILES['upl']['name'])){ //strip image of Exif data - which can be corrupt // use copy and then create thumbnail $iname = pathinfo($imgpath); $iname=$iname['filename']; $full=$updir."/".$iname."_full.".$extension; $medium=$updir."/".$iname."_medium.".$extension; $thumbnail=$updir."/".$iname."_thumbnail.".$extension; $image = new Imagick($imgpath); $image->stripImage(); // Writes resultant image to output directory //$image->writeImage($full); $image->destroy(); //resize image $size = getimagesize($imgpath); $owidth=$size[0]; $oheight=$size[1]; include("resize-class.php"); $width=$owidth; $height=$oheight; if($owidth > $oheight) { if($owidth >= 800) { $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(800,800,'landscape'); $resizeObj -> saveImage($full, 100); } else { copy($imgpath, $full); } $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(210,210,'landscape'); $resizeObj -> saveImage($medium, 100); $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(100,100,'landscape'); //crop image to 435px width by 220 height $resizeObj -> saveImage($thumbnail, 100); } if($owidth < $oheight || $owidth == $oheight){ if($owidth >= 800) { $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(800,800,'portrait'); $resizeObj -> saveImage($full, 100); } else { copy($imgpath, $full); } $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(210,210,'landscape'); //crop image to 435px width by 220 height $resizeObj -> saveImage($medium, 100); $resizeObj = new resize($imgpath); $resizeObj -> resizeImage(100,100,'landscape'); //crop image to 435px width by 220 height $resizeObj -> saveImage($thumbnail, 100); } $urlissue=0; // insert image details into database table $sqlins="INSERT INTO `caption_this_pic` (`hcuid`,`hcuname`,`hcemail`,`hcimgurl`,`hcimgwdth`,`hcimgheight`,`hcimagename`,`badurl`,`hc_path`,`hc_name`,`hc_ext`) VALUES ( ".$_SESSION["cp_userid"].", '".$_SESSION["nickname"]."', '".$_SESSION["cp_useremail"]."', '".$imgurl."', ".$width.", ".$height.", '".$imgname."', ".$urlissue.", '".$ipath."', '".$iname."', '".$extension."')"; $qins=mysql_query($sqlins) or $em=$em.mysql_error(); $hcid= mysql_insert_id(); $unixtime=time(); $blogdate=gmdate("F d, Y"); $thetitle="Caption This Pic ".$blogdate; $thebody='