Location: PHPKode > projects > CoreAsset > coreasset/photoadd.php
<?php
include("security.php");
?>
<?php
include("connection.php");
$photoname = $HTTP_POST_VARS['photo_name'];
$photoprice = $HTTP_POST_VARS['photo_price'];
$photoupload = $HTTP_POST_FILES['photo_upload_name']['name'];
//$status = $HTTP_POST_VARS['status'];
$status = "no";
$query = "insert into mtl_artgallery_photography (photo_name, photo_price, photo_upload_name, status) values ('$photoname', '$photoprice', '$photoupload', '$status')";
$result = mysql_query($query) or die(mysql_error());
$product_id = mysql_insert_id();

$uploadpath = '../photo_images/';      //here uploaded image files are stored.
$filename1 = $HTTP_POST_FILES['photo_upload_name']['name'];
$source1  = $HTTP_POST_FILES['photo_upload_name']['tmp_name'];
list($filename,$ext)=split('[/.-]',$filename1);     // find out extension of the image file

$fsize1=filesize($source1);

$file_size_max='1024000';
$file_size_max_wd='100k';

if($ext=='gif' or $ext=='GIF' or   $ext=='jpeg' or $ext=='JPEG' or $ext=='jpg' or $ext=='JPG' or $ext=='bmp' or $ext=='BMP')
{


       function getmicrotime()       // this function is used for renaming the uploaded image file
       {
         list($usec, $sec) = explode(" ", microtime());
         return ((float)$usec + (float)$sec);
        }

  	  if($filename1!="")
{


    $filename2 = $photoupload;
    $dest1 = $uploadpath.$filename2;
// upload the image
  if ( move_uploaded_file( $source1, $uploadpath.$photoupload) )
     {
         $photo_s=$dest1;

          // Thumbnail image creation.

         $image_attribs = getimagesize($photo_s);  //Get the size of an image

          if($ext=='jpeg' || $ext=='jpg' || $ext=='JPG' || $ext=='JPEG')
         $src = imageCreateFromJpeg( $photo_s ) ;           //for JPEG or JPG image file
							//Create a new image from file or URL

 if($ext=='gif' || $ext=='GIF')
          $src =imagecreatefromgif( $photo_s ) ;    //for GIF image file

  if($ext=='png' || $ext=='PNG')
          $src = imagecreatefrompng( $photo_s ) ;   //for PNG image file



  	if($ext=='bmp' || $ext=='BMP')
        			 	 $src = imagecreatefromwbmp( $photo_s ) ;   //for BMP image file

            $width =$image_attribs[0];
            $height =$image_attribs[1];

 $th_max_width = 100;  // the max width of thumbnail image desired
$th_max_height = 100;   // the max height of thumbnail image desired

// ratio calculation  to scale the  Thumbnail image

$ratio = ($width > $height) ? $th_max_width/$image_attribs[0] : $th_max_height/$image_attribs[1];

$th_width = $image_attribs[0] * $ratio;
$th_height = $image_attribs[1] * $ratio;


	/* create and output the destination image */
	$dest = imagecreatetruecolor($th_width,$th_height);  //Create a new true color image
	imageAntiAlias($dest,true);
	imagecopyresized( $dest, $src, 0, 0, 0, 0, $th_width,$th_height, $image_attribs[0], $image_attribs[1] );
           //Copy and resize part of an image

// thumbnail_image =>a folder,where Thumbnail image files are stored.
  $th_file_name = "../thumbnail_image/$filename2";

    if($ext=='jpeg' || $ext=='jpg' || $ext=='JPEG' || $ext=='JPG')
          imageJpeg($dest,$th_file_name,100);  //for JPEG or JPG image file
						// Output image to browser or file

          if($ext=='gif' || $ext=='GIF')
          imagegif($dest,$th_file_name,100);  ;    //for GIF image file


          if($ext=='png' || $ext=='PNG')
          imagepng($dest,$th_file_name,100);   //for PNG image file


          if($ext=='bmp' || $ext=='BMP')
          imagewbmp($dest,$th_file_name,100); //for BMP image file

    	 }
     else
     {
              // Header("Location:my_photos.php?error=1");
     }
}
else
{
$filename1="";
}}
 Header("Location: list_photography.php?type=1");
?>

Return current item: CoreAsset