?
Path : /home/enviro777/public_html/admin/ |
Current File : /home/enviro777/public_html/admin/insert1.php |
<?php ob_start(); include "include/connection.php"; $obj=new db(); if($_POST) { extract($_POST); $imageName=$_FILES['image']['name']; $source=$_FILES['image']['tmp_name']; move_uploaded_file($source, "comproducet/".$imageName); list($width, $height, $type, $attr) = getimagesize("comproducet/".$imageName); if($width > 491 or $height > 438) { chmod("comproducet/".$imageName, 0755); createthumb("comproducet/".$imageName, "comproducet/".$imageName,491,438); } $sql="insert into comproduct(`productId`, `proName`, `proDetails`, `proImage`, `date`) values ('', '$name', '$details', '$imageName', now())"; $obj->query($sql); header("location:addLatestLaunch.php?id=".$ptype."&st=success"); } function createthumb($name,$filename,$new_w,$new_h) { $system=explode(".",$name); if (preg_match("/jpg|jpeg/",$system[1])){$src_img=imagecreatefromjpeg($name);} if (preg_match("/png/",$system[1])){$src_img=imagecreatefrompng($name);} $old_x=imageSX($src_img); $old_y=imageSY($src_img); if ($old_x > $old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h); imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); if (preg_match("/png/",$system[1])) { imagepng($dst_img,$filename); } else { imagejpeg($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($src_img); } ?>