Detect if an image is loaded

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

miguelna
New php-forum User
New php-forum User
Posts: 15
Joined: Wed Sep 04, 2002 12:53 am

Detect if an image is loaded

Postby miguelna » Mon Oct 14, 2002 9:22 am

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…

DoppyNL

Postby DoppyNL » Mon Oct 14, 2002 9:49 am

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

miguelna
New php-forum User
New php-forum User
Posts: 15
Joined: Wed Sep 04, 2002 12:53 am

Postby miguelna » Mon Oct 14, 2002 10:02 am

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

DoppyNL

Postby DoppyNL » Mon Oct 14, 2002 10:16 am

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

Jay

Re: Detect if an image is loaded

Postby Jay » Mon Oct 14, 2002 11:23 am

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!


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest