Working on a prebuilt system that grabs remote images and saves them to a server.
Currently there is no checking on the image as to whether it indeed exists at that remote location, and it is of a certain file type (jpg, jpeg, gif) and I'm tasked with doing both.
I thought this was quite trivial as I'd simply use a simple regex and getimagesize($image):
$remoteImageURL = 'http://www.exampledomain.com/images/image.jpg';
if(@getimagesize($remoteImageURL) && preg_match("/.(jpg|gif|jpeg)$/", $remoteImageURL) )
{
// insert the image yadda yadda.
}
The problem occurs when I don't have any control over the url that I'm grabbing the image from, for example:
http://www.exampledomain.com/images/2?num=1
so when it comes to this, both the regex and getimagesize() will fail, is there a better way of doing this?