Re: How to download a picture thru http://?
| From: | Hugh Bothwell | Date: | Fri, 24 Aug 2001 15:42:20 +0000 |
| Subject: | Re: How to download a picture thru http://? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64273@lists.php.net to get a copy of this message | ||
"Tamas Bucsu" <ta.bucsu@orion-infotech.com> wrote in message
news:012c01c12c8b$49cf6750$1100020a@domain1...
> Is there any special way to get some pics from
> the web? Cos' what I wrote just does not work.
> Thanks
>
>
> if (file_exists($kepnev)){
>
> $kepnev="http://www.stg/pics/somethinggy.jpg"];
>
> $fdr = fopen($kepnev,"r");
> $fdw = fopen($kepnevshort,"w");
> while (!feof($fdr)) {
> fputs ($fdw,fgets($fdr, 4096));
>
> }
>
> fclose($fdr);
> fclose($fdw);
> }
> }
The simplest method, assuming
the file is web-accessible, is probably
echo "<img src='$kepnev'>";
If you really need to pass the raw image data
back (ie you're pulling it out of a database or
server file system or dynamically generating it),
you have to start with appropriate headers to
tell the browser how to treat what it's getting, ie
header("Content-Type: image/jpg");
Also, I bet it helps if you set $kepnev
_before_ you test whether it exists.