Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    144
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Dynamic Image Saving

    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 [html]<img alt="my alt tag" src="http://www.my-site.com/get.php?image_id=1" />[/html] 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?

  • #2
    New Coder
    Join Date
    Aug 2007
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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');
    Last edited by PhaZZed; 08-11-2007 at 01:35 AM. Reason: update

  • #3
    New Coder
    Join Date
    Aug 2007
    Location
    Wagga, Australia
    Posts
    59
    Thanks
    0
    Thanked 1 Time in 1 Post
    try this
    PHP Code:
    //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

    PHP Code:
    //saves dynamic image as name you want
    imagejpeg($image"/images/{$_GET["image_name"]}.jpg");
    header("Content-Type: image/jpeg");
    //displays it straight to browser
    imagejpeg($image); 
    Last edited by usik; 08-11-2007 at 01:53 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •