Search code examples
phpgetimagesize

getimagesize() error in php


So I am using the getimagesize function to get the size of the image. The line I use is the following:

list($width, $height) = getimagesize($imagen); 

The variable $imagen is the right one as if I echo it, I get the image url, and the image does exist. any idea?Edit: allow_url_fopen is on and the error I get is the following:

Warning: getimagesize(): Couldn't resolve host name in /home/u969736199/public_html/web/productos.php on line 43 Warning: getimagesize(http://snapi2.vv.si/web/images/productos/R2203054.jpg): failed to open stream: operation failed in /home/u969736199/public_html/web/productos.php on line 43 http://snapi2.vv.si/web/images/productos/R2203054.jpg

What I get from var_export($imagen); and var_export(is_readable($imagen)); is: http://snapi2.vv.si/web/images/productos/EE523152.jpg'http://snapi2.vv.si/web/images/productos/EE523152.jpg'false


Solution

  • If you are retrieving a remote image you need to make sure that you enable

    allow_url_fopen
    

    in php.ini.