Hey, I was wondering if someone can help me...
I need a php script that can goto a webpage that I specify, then find a *.jpg image IN A SPECIFIC folder I specify and then show it to me.
so basically it would goto
http://www.mysite.com/dailyimageshow
|
It would find the .jpg that is location at: http://www.mysite.com/images/dailyimages/2009//
and then grab that image onto another server without anything else.
is this possible? if so, how? (please note I am a newbie to programming, this is a project for church)
get a jpeg from a website script?
Moderator: General Moderators
-
chinstroker
- Forum Newbie
- Posts: 5
- Joined: Sun Apr 26, 2009 3:01 pm
Re: get a jpeg from a website script?
Does the image always have the same url?
If so, you can just use fopen($url, 'br') to get a handle on the data, then use fread() to either output it to the screen or save to a file.
If the url of the image changes, use $html = file_get_contents($urlOfPage) to get the html as a string, then use preg_match() using an appropriate pattern to search for to find the url of the image, then as above.
As ever, the PHP manual is your friend: php.net/fopen php.net/fread php.net/file_get_contents php.net/preg_match
If so, you can just use fopen($url, 'br') to get a handle on the data, then use fread() to either output it to the screen or save to a file.
If the url of the image changes, use $html = file_get_contents($urlOfPage) to get the html as a string, then use preg_match() using an appropriate pattern to search for to find the url of the image, then as above.
As ever, the PHP manual is your friend: php.net/fopen php.net/fread php.net/file_get_contents php.net/preg_match