View Full Version : Dynamic Image Saving

08-11-2007, 12:31 AM
I have a page thats sole function is to generate a dynamic image. When the image is loaded on screen, the only code within the source code body is
<img alt="my alt tag" src="http://www.my-site.com/get.php?image_id=1" /> When i right click on the image and try a "save as.." the suggested file name is *get.php.jpg*. So good so far.

What i want to do is load this page in the buffer or cache, then rename and save the generated image to a designated folder on my server, instead of displaying it. Once i save the image, i will just header() to another page for display. Is there a way to do what i describe?

08-11-2007, 12:33 AM
Surely you can just use some simple php to upload the file to a folder on the server?

bool rename ( string $oldname, string $newname [, resource $context] ) // rename your file

ie. rename('http://www.my-site.com/get.php?image_id=1','filename.jpg');

08-11-2007, 12:45 AM
try this

//this will grab the dynamically made picture, save it as a jpg in the folder images with the name picture
imagejpeg($image, "/images/picture.jpg");

then for the name just use a $_GET or $_POST variable to change the name, and you don't need to redirect to another page just do this

//saves dynamic image as name you want
imagejpeg($image, "/images/{$_GET["image_name"]}.jpg");
header("Content-Type: image/jpeg");
//displays it straight to browser

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum