PDA

View Full Version : PHP functions which return properties of remote files?



irc
Mon 30th Sep '02, 2:55pm
I want to be able to limit the size of images that get pulled into my pages via php. I was wondering if there is a function that will allow me to test the size of a particular image file on another site before I include it on the page.

Any ideas how to do this?

filburt1
Mon 30th Sep '02, 3:17pm
There's no direct way of doing it short of actually getting the file, saving it to a temp directory, getting its size, and then nuking it.

irc
Mon 30th Sep '02, 3:42pm
Hmm... it seems like I'll have to create a form which does that when they add the link of the image. That sounds like it would be too much overhead to do everytime it displays the page.

filburt1
Mon 30th Sep '02, 3:44pm
Right.

Remember if the image is huge your host will get annoyed at the extra bandwidth usage.

Scott MacVicar
Mon 30th Sep '02, 6:01pm
$size = getimagesize ("http://www.example.com/gifs/logo.gif");

and then $size[0] is width and $size[1] is height.

irc
Tue 1st Oct '02, 1:53pm
That's helpful, thanks! I'll give it a try. At least I could limit the dimensions. Still no idea on the size thing though, right?