Search code examples
phpsslhttpsopensslgetimagesize

PHP function getimagesize() gives "Read error" when trying to get https url


I am trying to use getimagesize with URL and with http everything is fine. However when trying to use function on https url I am getting "Read error" Notice and false as result. I checked and I have OpenSSL 0.98 installed on the server (so it should be working with https as well). I know that I can download the image first and then use it but it seems to me like this should work and that I am missing something. Could you please provide me with some solution (other than downloading the image first and then opening it) ?

Thank you in advance.


Solution

  • You can use file_get_contents() as an alternate solution..

    <?php
    $filename='something';
    file_put_contents($filename,file_get_contents($url));
    $size = getimagesize($filename);
    var_dump($size);