Thursday, January 3, 2013

PHP - Problem in saving the image using imagepng

Probably you are familiar with the code below.
I am assuming that you successfully prints the image 
and only having a problem in saving it.
This code will do the solution!
Tested and working! 

header( "Content-type: image/png" ); // this will print your image imagepng($img); // set where you want your image to be saved // take note that you have to save the image // into another directory for this to work. $filename = "any_name"; $directory = "folder/".$filename.".png"; // set the directory with 0755 permission chmod($directory,0755); // this will save your image imagepng($img, $directory, 0, NULL); imagedestroy($img);

No comments:

Post a Comment