1

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?

1
  • note that many times, the first error is the error that matters. in this case it is telling you that you attempted to divide a number by zero (see the answers below). It seems obvious that you did not mean to divide. Commented May 3, 2012 at 15:45

2 Answers 2

3

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']);
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.