Revision: 20831
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 26, 2009 08:46 by ksantoshp
Initial Code
if(!empty($_FILES)){ $img = explode('.', $_FILES['thumb_img']['name']); $img_path = $img_dir .$img[0].time().'.'.$img[1]; $img_thumb = $img_dir .$img[0].time().'_thumb.'.$img[1]; $extension = strtolower($img[1]); if(in_array($extension , array('jpg','jpeg', 'gif', 'png', 'bmp'))){ //---------- To create thumbnail of image--------------- if($extension=="jpg" || $extension=="jpeg" ){ $src = imagecreatefromjpeg($_FILES['thumb_img']['tmp_name']); } else if($extension=="png"){ $src = imagecreatefrompng($_FILES['thumb_img']['tmp_name']); } else{ $src = imagecreatefromgif($_FILES['thumb_img']['tmp_name']); } list($width,$height)=getimagesize($_FILES['thumb_img']['tmp_name']); $newwidth=151; $newheight=151;//($height/$width)*$newwidth; $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); imagejpeg($tmp,$img_thumb,100); //-------------- Ends ----------- move_uploaded_file($_FILES['thumb_img']['tmp_name'], $img_path); $blog_thumb = get_site_option('rt_blog_thumb'); $blog_thumb[$blog_id] = basename($img_thumb); update_site_option('rt_blog_thumb', $blog_thumb); } else echo 'Invalid file'; }
Initial URL
Initial Description
Initial Title
Create Image thumb while uploading
Initial Tags
image
Initial Language
PHP