Hi I'm looking for some help to get image data from ubid.com auctions using php and curl. I have managed to scrape the url of an image - this looks like this: http://static.ubid.com/mgen/vximg/scale.ms?args=%221_10203259_0.jpg%22,275,275 Code (markup): If I wrap an html img tag around this, the image displays ok. When I try to use getimagesize(), it returns an empty array as though the file does not exist. First person to help me solve this issue gets $10 Thanks, Joe
getimagesize expects a valid file hosted on your own server, thus you will have to download the image before being able to get it's size. preg_match('#args=%(.*?)%#si', $image_url, $filename); // Get the filename (stored as $filename[1]); curl_setopt($ch, CURLOPT_URL, $image_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $data = curl_exec($ch); file_put_contents('temporary/'.$filename[1], $data); // Store the file print_r(getimagesize('temporary/'.$filename[1])); unlink('temporary/'.$filename[1]); // Delete the file --------- This should help you, please donate the $10 to a charity. PS: Make sure to create the temporary directory and chmod it to 777. There are alternative ways on how to do this however unless you're very experienced at cUrl this is the most suitable method for you.
Wrong. "It can reference a local file or (configuration permitting) a remote file using one of the supported streams." http://php.net/manual/en/function.getimagesize.php If you have the http:// wrapper enabled, the following works: <?php print_r(getimagesize('http://static.ubid.com/mgen/vximg/scale.ms?args=%221_10203259_0.jpg%22,275,275')); ?> PHP:
This has now been sorted. The problem was that I needed to use trim on the variable that I was using to hold the image url - there must have been white space at one or both ends of the variable. Thanks to everyone that offered help. Joe
No, you are incorrect as already pointed out by several people in this thread. My issue was that there was whitespace in the url