user979331
user979331

Reputation: 11861

php getimagesize errors

Im trying to get the image size for an image in my server and the data is in a database or my getimagesize function looks like this

$size = getimagesize(upload/$array['image']);
print_r($size);

I get these errors back...

Warning: Division by zero in /home/content/44/8713044/html/view/home/home.html on line 81

Warning: getimagesize() [function.getimagesize]: Filename cannot be empty in /home/content/44/8713044/html/view/home/home.html on line 81

the image is in the right place...what am I doing wrong?

Upvotes: 1

Views: 1113

Answers (2)

ajreal
ajreal

Reputation: 47321

you should quote the string like this :

getimagesize("upload/{$array['image']}");

otherwise, PHP will treat this as a mathematic expression

this url might help :- http://www.php.net/manual/en/language.expressions.php

Upvotes: 1

Wiseguy
Wiseguy

Reputation: 20873

Your path isn't in quotes, so it's not a string.

$size = getimagesize(upload/$array['image']);

It's trying to mathematically divide a constant named upload by $array['image'].

Use quotes and concatenate like this:

$size = getimagesize('upload/' . $array['image']);

Upvotes: 4

Related Questions