Page 1 of 1

Detect if an image is loaded

Posted: Mon Oct 14, 2002 9:22 am
by miguelna
I have an image generated by PHP (image1.php?aa=23&bb=125874). Sometimes this image is not loaded. Can I detect if the image is loaded or not?
I tried

Code: Select all

fopen (“image1.php?aa=23&bb=125874”, “r”)
, but the first argument is invalid…

Posted: Mon Oct 14, 2002 9:49 am
by DoppyNL
If an image is not shown there is some reason it isn't.
perhaps its a better idea to find out why the image isn't loaded!
If you solve that you won't have to check if the image is loaded.

Then again, I don't know what the image is for, simply for displaying on a webpage?

Greetz Daan

Posted: Mon Oct 14, 2002 10:02 am
by miguelna
it's a simple image to display in a web page. Sometimes the variable bb is not availlable, and the image is not loaded. I want detect if yhe image is not loaded, because the i don't control the bb var.

Thanks

M

Posted: Mon Oct 14, 2002 10:16 am
by DoppyNL
You say the image isn't loaded because the bb-variable is not available. Simple check is to check if it is available or not.

you can check if bb is set with:

Code: Select all

isset($_GET['bb']); //-- PHP 4.1.0 and higher
isset($_HTTP_GET_VARS['bb']); //-- before that

note: this works with every variable :)

If it is not set you can set it you'reself with a default value and the image will load normally. Or you know the image cannot be loaded.

Greetz Daan

Re: Detect if an image is loaded

Posted: Mon Oct 14, 2002 11:23 am
by Jay
miguelna wrote:I have an image generated by PHP (image1.php?aa=23&bb=125874). Sometimes this image is not loaded. Can I detect if the image is loaded or not?
I tried

Code: Select all

fopen (“image1.php?aa=23&bb=125874”, “r”)
, but the first argument is invalid…

Correct me if I'm wrong, but it seems you want to use a script to generate the path to the file you want to open? It doesn't work like that. You have to specify the path yourself!