Re: Transfering an image
| From: | Steve Werby | Date: | Thu, 26 Apr 2001 16:56:38 +0000 |
| Subject: | Re: Transfering an image | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-50480@lists.php.net to get a copy of this message | ||
"Ben Quinn" <benquinn@optushome.com.au> wrote:
> I am trying to copy an image from an external server and save it to my
own.
> I have the following script to do this for a txt file and it works great!
>
> ?>
>
> $page = "../temp/yep.txt";
>
> $date = date("http:/www.example.com/yep.txt");
>
> $cartFile = fopen("$page","a");
> fwrite($cartFile,$date,strlen($date));
> fclose($cartFile);
>
> ?>
>
> But i can't get it to work for image files - the images are saved and
> displayed on screen as a whole bunch of rubbish.
That's because your browser doesn't know the data is an image. Before you
send the image to the browser you have to use the header() function to send
the browser the proper mime type for the image. I don't know the mime type
off-hand, but there's probably a tutorial on zend.com or phpbuilder.com that
discusses saving images in a MySQL DB and pulling them out to display on a
webpage using PHP so find one of those articles and look near the end.
--
Steve Werby
President, Befriend Internet Services LLC
http://www.befriend.com/