Re: dynamic <img>

From: Date: Tue, 18 Sep 2007 15:33:09 +0000
Subject: Re: dynamic <img>
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-262202@lists.php.net to get a copy of this message
Daniel Brown wrote:
    Hello, Anugrah.
On 9/18/07, Anugrah Widya <anuwidy@gmail.com> wrote:
i have problem with dynamic image displaying here the snippets thumb.php <?php header("Content-type: image/jpg"); $file = "data/original/filename.jpg"; readfile($file); ?> img.php <img src="thumb.php?filename.jpg" />
    From your above examples, two questions come to mind:
        1.) Is thumb.php in a folder above data?  If not, adjust
your path accordingly.
        2.) When using the query ?filename.jpg are you going to call
that as an $argv[1] variable? If you want to use it as a $_GET, $_POST, or $_REQUEST, it will need a variable name with an assigned value. For example:
            <img src="thumb.php?img=filename.jpg">
L>thumb.php <?
    $path = "../data/original/"; // In case it's a same-level
directory as the PWD
    $img = $_GET['img'];
    header("Content-type: image/jpg");
    readfile($path.$img);
?> -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 Give a man a fish, he'll eat for a day. Then you'll find out he was allergic and is hospitalized. See? No good deed goes unpunished....
thank you Mr. Brown for your reply, yep thumb.php and img.php are in the same level correction for img.php <img src="thumb.php?url=filename.jpg" /> i don't know what wrong with it, when i save the image data to another files, the image didn;t corrupted, but when displayed dynamically it's corrupted.., and the path are ok ;) did i miss something on this, and i didn;t aware of it ?

« previous php.general (#262202) next »