![]() |
Image return /print
Hey all,
well i am also a newbie :) i saw this on many sites: <img src="somephp.php?blabla" width="100"> how can i make that to? i want to reffer to a php file that returns or prints a jpg image and in the <img src=must be a php url> Best regards M |
Re: Image return /print
me wrote:
> Hey all, > well i am also a newbie :) > > i saw this on many sites: > <img src="somephp.php?blabla" width="100"> > > how can i make that to? > > i want to reffer to a php file that returns or prints a jpg image and in > the <img src=must be a php url> > > Best regards M Hi, You should somephp.php?blabla return an image, including the right headers for MIME-TYPE and such. Should work as you described above. The trouble will be generating a script that does that. You will have to do some more research on imagelibs in PHP. Good luck, Erwin Moller |
Re: Image return /print
"Erwin Moller" <since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in message news:3f780f80$0$58709$e4fe514c@news.xs4all.nl... > me wrote: > > > Hey all, > > well i am also a newbie :) > > > > i saw this on many sites: > > <img src="somephp.php?blabla" width="100"> > > > > how can i make that to? > > > > i want to reffer to a php file that returns or prints a jpg image and in > > the <img src=must be a php url> > > > > Best regards M > > Hi, > > You should somephp.php?blabla return an image, including the right headers > for MIME-TYPE and such. > Should work as you described above. > > The trouble will be generating a script that does that. You will have to do > some more research on imagelibs in PHP. > > Good luck, > Erwin Moller Thanks, i did some testing with this code: header("Contet-type: image/jpeg"); $theURL="image.jpg"; if(!($fp=fopen($theURL,"rb"))) { print("Could not open the URL."); exit; } $contents=fread($fp,1000000); print($contents); fclose($fp); But must i always set the header("Contet-type: image/jpeg") before the code begins or can i make first a musql query orso to get the rigth image and then print the header("Contet-type: image/jpeg");? |
Re: Image return /print
me wrote:
> > "Erwin Moller" > <since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in > message news:3f780f80$0$58709$e4fe514c@news.xs4all.nl... >> me wrote: >> >> > Hey all, >> > well i am also a newbie :) >> > >> > i saw this on many sites: >> > <img src="somephp.php?blabla" width="100"> >> > >> > how can i make that to? >> > >> > i want to reffer to a php file that returns or prints a jpg image and >> > in the <img src=must be a php url> >> > >> > Best regards M >> >> Hi, >> >> You should somephp.php?blabla return an image, including the right >> headers for MIME-TYPE and such. >> Should work as you described above. >> >> The trouble will be generating a script that does that. You will have to > do >> some more research on imagelibs in PHP. >> >> Good luck, >> Erwin Moller > > Thanks, > > i did some testing with this code: > > header("Contet-type: image/jpeg"); that is content-type, no contet-type. > $theURL="image.jpg"; > if(!($fp=fopen($theURL,"rb"))) > { > print("Could not open the URL."); this is a bit odd. You have set the header to image, but your output is plain text.. Not good. Your html-page is asking for an image, and your script should return one. In your case, where it cannot find the right image, try to send back an image you know that exists containing "NOT AVAILABLE" written on it or somethinf like that. Do not send plain text to the browser when it expects an image. Better write an error to some logfile. > exit; > } > $contents=fread($fp,1000000); > > > print($contents); > fclose($fp); > > > But must i always set the header("Contet-type: image/jpeg") before the > code begins or can i make first a musql query orso to get the rigth image > and then print the header("Contet-type: image/jpeg");? You can do whatever you like AS LONG AS YOU DO NOT GENERATE OUTPUT. :-) The headers should come first. |
Re: Image return /print
On 29-Sep-2003, "me" <someone@microsoft.com> wrote: > i saw this on many sites: > <img src="somephp.php?blabla" width="100"> > > how can i make that to? <img src="getimage.php?fn=image1" ...> getimage.php: <?php if (isset($_GET['fn'])) $image = $_GET['fn']; else $image = 'error'; header("Content-Type: image/jpeg\n"); header("Content-Transfer-Encoding: binary"); $fp=fopen("images/$image.jpg" , "r"); if ($fp) fpassthru($fp); ?> -- Tom Thackrey www.creative-light.com |
Re: Image return /print
"me" <someone@microsoft.com> wrote in message news:YvUdb.391862$0W5.11564308@pollux.casema.net.. . > > "Erwin Moller" > <since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in > message news:3f780f80$0$58709$e4fe514c@news.xs4all.nl... > > me wrote: > > > > > Hey all, > > > well i am also a newbie :) > > > > > > i saw this on many sites: > > > <img src="somephp.php?blabla" width="100"> > > > > > > how can i make that to? > > > > > > i want to reffer to a php file that returns or prints a jpg image and in > > > the <img src=must be a php url> > > > > > > Best regards M > > > > Hi, > > > > You should somephp.php?blabla return an image, including the right headers > > for MIME-TYPE and such. > > Should work as you described above. > > > > The trouble will be generating a script that does that. You will have to > do > > some more research on imagelibs in PHP. > > > > Good luck, > > Erwin Moller > > Thanks, > > i did some testing with this code: > > header("Contet-type: image/jpeg"); > $theURL="image.jpg"; > if(!($fp=fopen($theURL,"rb"))) > { > print("Could not open the URL."); > exit; > } > $contents=fread($fp,1000000); > > > print($contents); > fclose($fp); > > > But must i always set the header("Contet-type: image/jpeg") before the code > begins or can i make first a musql query orso to get the rigth image and > then print the header("Contet-type: image/jpeg");? > > > Maybe try "Content-type" and not "Contet-type" :) |
Re: Image return /print
On Mon, 29 Sep 2003 15:54:32 GMT, "Tom Thackrey"
<tomnr@creative-light.com> wrote: ><img src="getimage.php?fn=image1" ...> > >getimage.php: ><?php > >if (isset($_GET['fn'])) > $image = $_GET['fn']; >else > $image = 'error'; > >header("Content-Type: image/jpeg\n"); >header("Content-Transfer-Encoding: binary"); > >$fp=fopen("images/$image.jpg" , "r"); >if ($fp) > fpassthru($fp); > >?> another way to do it: getimage.php: <?php if (isset($_GET['fn'])) { $image = $_GET['fn']; header("Location: images/$image.jpg"); } else { header("HTTP/1.0 404 Not Found"); } ?> - allan savolainen |
Re: Image return /print
Jason wrote:
> > "me" <someone@microsoft.com> wrote in message > news:YvUdb.391862$0W5.11564308@pollux.casema.net.. . >> >> "Erwin Moller" >> <since_humans_read_this_I_am_spammed_too_much@spam yourself.com> wrote in >> message news:3f780f80$0$58709$e4fe514c@news.xs4all.nl... >> > me wrote: >> > >> > > Hey all, >> > > well i am also a newbie :) >> > > >> > > i saw this on many sites: >> > > <img src="somephp.php?blabla" width="100"> >> > > >> > > how can i make that to? >> > > >> > > i want to reffer to a php file that returns or prints a jpg image and > in >> > > the <img src=must be a php url> >> > > >> > > Best regards M >> > >> > Hi, >> > >> > You should somephp.php?blabla return an image, including the right > headers >> > for MIME-TYPE and such. >> > Should work as you described above. >> > >> > The trouble will be generating a script that does that. You will have >> > to >> do >> > some more research on imagelibs in PHP. >> > >> > Good luck, >> > Erwin Moller >> >> Thanks, >> >> i did some testing with this code: >> >> header("Contet-type: image/jpeg"); >> $theURL="image.jpg"; >> if(!($fp=fopen($theURL,"rb"))) >> { >> print("Could not open the URL."); >> exit; >> } >> $contents=fread($fp,1000000); >> >> >> print($contents); >> fclose($fp); >> >> >> But must i always set the header("Contet-type: image/jpeg") before the > code >> begins or can i make first a musql query orso to get the rigth image and >> then print the header("Contet-type: image/jpeg");? >> >> >> > > Maybe try "Content-type" and not "Contet-type" :) Hi Jason, That might help maybe. ;-) |
| All times are GMT +1. The time now is 05:37 AM. |
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0