Jump to content

file_exists doesn't work for images on url


preetham

Recommended Posts

Thanks.

 

This seems to be working fine.

 

However, i see some performance issue, I mean , it takes 3 secs more time now.

 

Is it because of this or something else?

You can store the files on your server temporarily and then use getimagesize.

First, Don't use getimagesize() for this, it downloads the whole image. Use cURL, which can ask the remote server for only the HTTP headers, which will return status=200 or status=404, etc.

 

Second: ofcourse there is a performance issue if you are going to verify each image every time, which is why you would cache the results in a file somewhere.

You can store the files on your server temporarily and then use getimagesize.

 

for storing it on my server, i can use file_exists itself. 

I'm having issue for remote images.

 

 

First, Don't use getimagesize() for this, it downloads the whole image. Use cURL, which can ask the remote server for only the HTTP headers, which will return status=200 or status=404, etc.

 

Second: ofcourse there is a performance issue if you are going to verify each image every time, which is why you would cache the results in a file somewhere.

Thanks for the advice,

 

I will check on this asap.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.