Search code examples
phpgd

How to save an image without using the imagepng() function?


So I have been manipulating images using the GD library, and would like to first save those images and then redirect the user to another page. However, with the imagepng() function that appears to be impossible.

see below:

/// image manipulations beforehand
imagepng($image, $savepath);
echo '<meta http-equiv="refresh" content="0;URL=different_page.php"/> ';

Whilst it does save the images in question, it doesn't allow for any redirections afterwards. Hence my question: what other way is there to save these images without using imagepng?


Solution

  • Do not use meta element with php to redirect, use php location header.

    imagepng($image, $savepath);
    header('Location: different_page.php');