|
Posted by Kim Andrι Akerψ on 02/03/07 00:43
artlover70@yahoo.com wrote:
> Hi everyone !
>
> I am just wondering if capturing an image remotely with php is
> doable ?
>
> I am working on a project for my department where I need to write php
> code to capture an remote image and save it to a local folder/web site
> directory given an image's URL.
>
> Have anyone done anything like this ? If you have, do you mind share
> your ideas/sample code ?
This will work in PHP 4.3.0 and above, and if allow_url_fopen is
enabled:
<?php
$img = imagecreatefromjpeg("http://example.com/path/to/image.jpg");
imagejpeg($img, "localimage.jpg");
?>
Alternately, if image functions are disabled, this might work:
<?php
$imagedata = file_get_contents("http://example.com/path/to/image.jpg");
$newfile = fopen("localimage.jpg", "w");
fwrite($newfile, $imagedata);
fclose($newfile);
?>
--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Navigation:
[Reply to this message]
|