Re: =.jpg from another URL with PHP=

From: Date: Fri, 11 Oct 2002 14:53:13 +0000
Subject: Re: =.jpg from another URL with PHP=
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119648@lists.php.net to get a copy of this message
First of all you have to open this file as a binary e.g. fopen("myfile.jpg","rb"); then you shound send the apropriate html headers to display the image e.g. header("Contet-type: image/jpeg"); "Anthony Ritter" <tony@gonefishingguideservice.com> wrote in message news:20021011144729.465.qmail@pb1.pair.com... > The following script picks up single .jpg image of a doppler weather map > from another URL: > ....................................... > <? > $theURL="http://image.weather.com/web/radar/us_har_closeradar_medium_usen.jp > g"; > if(!($fp=fopen($theURL, "r"))) > { > print("Could not open the URL."); > exit; > } > $contents=fread($fp,1000000); > print($contents); > fclose($fp); > ?> > ...................................... > > However, when I try to insert the HTML tages into the script like: > > ...................................................... > <HTML> > <HEAD> > <BODY> > This is a map. > <? > $theURL="http://image.weather.com/web/radar/us_har_closeradar_medium_usen.jp > g"; > if(!($fp=fopen($theURL, "r"))) > { > print("Could not open the URL."); > exit; > } > $contents=fread($fp,1000000); > print($contents); > fclose($fp); > ?> > </BODY> > </HTML> > .......................................................... > > I get the following: > ÿØÿàJFIFÿþ 1034364214ÿÛC > 2!=,.$2I@LKG@FEPZsbPUmVEFd^emw{,N`-O}-s~|ÿÛC;!!;|SFS > ||||||||||||||||||||||||||||||||||||||||||||||||||ÿÀ)¸"ÿÄ > ÿÄH!1A"Qaq#2'¡BR±ÁÑ3áð$brñ45CSs' > "DTt,cf²ÂÒÿÄÿÄ*!1AQ"aq2B'¡ÑðáÿÚ > ?óz_Yª<Måm ·Lë?öW"Â-O¨x¹xâ'Ý~~?ö|ñ½s > þyè¢Ñ7þ?©ø¶®xbÒÛ°ó,Ï}`Òç!W-ü$g®NÕ&³jIº'×ZTÔѶ«SðD > Qö-yÕ+Q>_§L{M2Iý©Ô3¡q£! > etc. etc... > > I would like to insert additional text copy with this map - is this > possible. > > Thanking all in advance. > Tony Ritter > > >

« previous php.general (#119648) next »