Re: FOPEN For Getting Images From Another Site
| From: | Matthew Leverton | Date: | Thu, 13 Jul 2000 15:33:37 +0000 |
| Subject: | Re: FOPEN For Getting Images From Another Site | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-6461@lists.php.net to get a copy of this message | ||
It should be possible, but the reason it doesn't work for you is because the
"filesize" doesn't work on URLs. Try this:
$fcontents = join( '', file( 'http://www.php.net' ) );
That's straight from the manual, and I haven't tried it on images, but it
should work. The file() simply places the entire contents of a file into an
array separated by new lines. Since it's binary, the join() should piece it
back together, I think... There's probably an even better way of doing it.
Check out the file system functions in the docs, and you may come across
something better.
--
Matthew Leverton - matthew@aeroinc.net -
http://www.allegro.cc
-----Original Message-----
From: Jeff Gannaway <webmaster@cactusgraphics.com>
To: php-general@lists.php.net <php-general@lists.php.net>
Date: Thursday, July 13, 2000 10:27 AM
Subject: [PHP] FOPEN For Getting Images From Another Site
>I tried this the way I thought it would work without any success.
>
>I need to copy thousands of images form our suppliers' web site to our
>retail web site. They've given us permission to do so, but won't let us do
>it any simple way (FTP, sending us a CD ROM or ZIP disk, etc). I'd like to
>save a day of headaches by writing a PHp scrip tthat will read the
>filenames (which I already know) and save them on my server. I tried using
>this method to read them:
>
><?
>$filename =
>"http://www.theirsite.com/graphics/imagename.jpg";
>$fd = fopen ($filename, "r");
>$contents = fread ($fd, filesize ($filename));
>
>$x = filesize($filename);
>print "x = $x<BR>
>$contents";
>
>fclose ($fd);
>?>
>
>x (the filesize) came up as null value and it didn't display the contents.
>
>Am I dreaming, or is this possible?
>
>Thanks,
>Jeff
>