|
Posted by Jochem Maas on 01/13/05 22:29
John Camp wrote:
> I was able to successfully make a very simple http proxy - turns out the
> php documentation has the code for this =] - but now I need a way to
> display images. I figured the best way would be to download the images
> to a temporary folder, then parse the html to point to the images on my
> server instead. The problem is that I do not know how to download the
> images.
$imgdata = file_get_contents("http://somedomain.com/someimage.jpg");
but this assumes that your php setup has the allow_url_fopen ini setting
set to true/1, see here for more info:
http://nl2.php.net/manual/en/ref.filesystem.php#ini.allow-url-fopen
if not then the only other way _I_ can think of, using PHP, is using the
cURL extension - which maynot be available either :-S
>
> Also if anyone has a link to a parsing script it would save a good
> amount of time.
regexps is the way to go, I did a quick google and found this post:
http://forums.devshed.com/t173149/s.html&highlight=parse+image
there is a little code snippet there which might be a starting point for
you.
here is an untested regexp which goes a little further, it assumes that
the img tags have the src attr properly delimited and specifically
delimited with doublequotes.
|<img [^>]*src="([^"]*)"[^>]*>|i
hope that helps you on your way.
(hey list-guys! look no rtfm'ing in sight!)
>
> Thanks for any help.
>
[Back to original message]
|