Page 1 of 1

Saving php created graphics [SOLVED]

Posted: Fri Sep 14, 2007 12:23 am
by cturner
Can someone please tell me how I can save a php created image to another folder other than the php code folder? I desperately need to see code not a link. Thanks in advance.

Here is my code:

Code: Select all

function makeimage ($title3, $im) {
    $im = @imagecreate(110, 23) or die('Cannot Initialize new GD image stream.');
    imagecolorallocate($im, 0, 57, 122);
    $tc = imagecolorallocate($im, 255, 255, 255);
    imagestring($im, 3, 10, 5,  $name, $tc);
    imagejpeg ($im, '/images/'.$title3.'btn.jpeg');
    imagedestroy($im);
}
    makeimage ($title3, $im);

Posted: Fri Sep 14, 2007 12:32 am
by s.dot
You can save it anywhere you want, using the second parameter of imagejpeg()

Posted: Fri Sep 14, 2007 12:35 am
by feyd
Your code already wishes to place it in /images. Now that would be in the root of the server, not the root of the website. $_SERVER['DOCUMENT_ROOT'] may be useful here if you wish to place the file in your website's root.

Posted: Fri Sep 14, 2007 5:36 pm
by cturner
The problem is now solved. The solution was taking the first / out of imagejpeg ($im, '/images/'.$title3.'btn.jpeg');.