Getimagesize() filename URL

There is this werid thing that seems to be going wrong with the getimagesize() function.
According to the documentation, the getimagesize() function suppose to work even with a remote image file. So say if I use it this way, getimagesize(“”); it would still work.

It was working some months ago on one of my scripts until recently when I try to run the script again, it doesn’t work anymore. What’s more is the URL of the image that I put in the getimagesize() function is an image in the same sandbox as the script. I have something like getimagesize(“http://localhost/testsite/images/testimage.jpg”);

I have no idea why it doesn’t work and it throws an error on the page after getting the execution timeout.

Warning: getimagesize(http://localhost/testsite/images/testimage.jpg) [function.getimagesize]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\htdocs\ estsite\showimage.php on line 127

It however works when I have the argument as a relative path this way: getimagesize(“images/testimage.jpg”);

Does anyone has any idea why it didn’t work, even when the URL of the image is actually linking back to an image on the same sandbox?


Does this happen only with getimagesize or also with fopen? Have you tried with instead? Give us more information, please. :slight_smile:

I have just tried instead and it seemed to work.
But why doesn’t the localhost address work when the IP of is also localhost?

I have also tried the fopen with localhost address and I get similar error of failed to open stream. I just realise that the fopen is also having the same problem after you suggested me to try that.

I made another discovery. The localhost address doesn’t even work when I load PHP vars in Flash. But it works with that IP.

So the localhost address only works for showing the page on the browser. What is wrong with this?