upload png image with transparency code but it not working and also showing the bug while uploading image
<p>upload png image with transparent code but it not working and also showing the bug while uploading image </p>

<pre><code>         &lt;?php
     header("Content-type: image/png");     
     $size = 200; // the thumbnail height
     //$size1 = 200; // the thumbnail height
     $filedir = 'uploads/'; // the directory for the original image
     $thumbdir = 'uploads/'; // the directory for the thumbnail image
    // $filedir1 = 'uploads/'; // the directory for the original image
    // $thumbdir1 = 'uploads/'; // the directory for the thumbnail image


     $prefix = 'small_'; // the prefix to be added to the original name
     //$prefix1 = 'large_'; // the prefix to be added to the original name
     $maxfile = '2000000';
     //$maxfile1 = '2000000';
     $mode = '0666';
     //$mode1 = '0666';
    // $userfile_name = $_FILES['image']['name'];
      $rnd_1 = rand(11111,99999);
      //$rnd_1_1 = rand(11111,99999);

     $userfile_name= $rnd_1.'_'.$_FILES['image']["name"];
     $userfile_tmp = $_FILES['image']['tmp_name'];
     $userfile_size = $_FILES['image']['size'];
     $userfile_type = $_FILES['image']['type'];
     if (isset($_FILES['image']['name'])) 
     {
         $prod_img = $filedir.$userfile_name;
         $prod_img_thumb = $thumbdir.$prefix.$userfile_name;
         move_uploaded_file($userfile_tmp, $prod_img);
         chmod ($prod_img, octdec($mode));
         $sizes = getimagesize($prod_img);
        $aspect_ratio = $sizes[1]/$sizes[0]; 
         if ($sizes[1] &lt;= $size)
         {

             $new_width = '141';
             $new_height = '141';
         }else{

             $new_width = '141';
             $new_height = '141';

            /* $new_height = $size;
             $new_width = abs($new_height/$aspect_ratio);*/
         }
       $destimg=ImageCreateTrueColor($new_width,$new_height)
             or die('Problem In Creating image');



        if($userfile_type=='image/jpeg' || $userfile_type=='image/jpg')
             {
         $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image');
             }

             if($userfile_type=='image/gif')
             {            
        $srcimg=imagecreatefromgif($prod_img)   or die('Problem In opening Source Image');   
             }

              if($userfile_type=='image/png')
             {            

        $srcimg=imagecreatefrompng($prod_img)   or die('Problem In opening Source Image');  

        imagesavealpha($srcimg, true);
        //setting completely transparent color
        $transparent = imagecolorallocatealpha($srcimg, 0, 0, 0, 127);
        //filling created image with transparent color
        imagefill($srcimg, 0, 0, $transparent);
        imagepng($srcimg);
        //imagedestroy($im);


                     }


        if(function_exists('imagecopyresampled'))
         {
             imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
             or die('Problem In resizing');
         }else{
             Imagecopyresized($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg))
             or die('Problem In resizing');
         }
         ImageJPEG($destimg,$prod_img_thumb,90)
             or die('Problem In saving');
         imagedestroy($destimg);



     }

            ?&gt;
</code></pre>

<p>*<em>Here My transparency code *</em></p>

<pre><code>  $srcimg=imagecreatefrompng($prod_img) 
  or die('Problem In opening Source Image');    
  imagesavealpha($srcimg, true);
  //setting completely transparent color
  $transparent = imagecolorallocatealpha($srcimg, 0, 0, 0, 127);
  //filling created image with transparent color
  imagefill($srcimg, 0, 0, $transparent);
  imagepng($srcimg);
  //imagedestroy($im);
</code></pre>

<p><strong>But It Showing This Bug While Uploading Png Image</strong>        </p>

<pre><code>‰PNG  IHDRúðU›5 IDATxœì½Ù¯%YvÞ÷ÛkçÜsî½9VÖ\=TU“Í¡"EË°ò³ŸèdÓÒ°ž˜ülX/6`
</code></pre>

<p><strong>Any One Can Help Me Thanks In Advance</strong></p>
