title: imagepng shows "cannot be displayed" error
body: <p>I dunno why, but there's something weird about imagepng. Whenever i use <code>imagepng($image_p,NULL,9);</code> it uploads the file and displays it on the page but when i use <code>imagepng($image_p,'upload/test.png',9);</code> it does upload the image, but the page returns the message "The image <em>_</em> cannot be displayed, because it contains errors." and the succeeding codes will not work.</p>
  
  <p>Can you guys please tell me what I'm doing wrong here?</p>
  
  <p>here's the more detailed code:</p>
  
  <pre><code>$im = imagecreatefrompng($filename2);
  $size = getimagesize($filename2);
  $w = $size[0];
  $h = $size[1];
  $nw = 200;
  $nh = 200;
  $image_p = imagecreatetruecolor($nw,$nh);
  imagecopyresampled($image_p,$im,0,0,$_GET['left']*1,$_GET['top']*1,$nw,$nh,$_GET['width']*1,$_GET['height']*1);
  header('Content-Type: image/png');
  $fn1 = "fin_".substr(uniqid(md5(rand()), true),0,10).".".$extension;
  imagepng($image_p,'upload/'.$fn1,9);
  </code></pre>