Search code examples
phpphp-5.5getimagesize

getimagesize hangs indefinitely


The server I am on was recently upgraded, and PHP went from 5.2 to 5.5. I have a script that uses getimagesize(), and it worked fine on 5.2, but now the functions hangs indefinitely on the 5.5. I get no error codes, no return value of false, and no return value at all. Based on some of the other posts around, I checked some "standard" things:

  • allow_url_fopen is set to 'on' in the php environment
  • I am using absolute filepaths beginning with https:// and ending in .png
  • the files exist
  • even with ini_set('display_errors', 1) and error_reporting(E_ALL), no error messages are displayed

I have tried testing the function using Chrome, Firefox, and CLI, but nothing works. Is there anything else I can check?


Solution

  • When using absolute filepaths with the getimagesize() function, ensure that the absolute filepath is the absolute server filepath, not just the domain, TLD and filepath as displayed in the browser URI bar.

    The same applies to using absolute filepaths with:

    include

    scandir()

    rmdir()

    unlink()

    and many other PHP functions.