-1

update_image.php

if($image_width > $data2['maxwidth'] or $image_height > $data2['maxheight'])
                    {
                    echo '<br>'."Image is too big".'<br>';
                    echo $image_width.'>'.$data2['maxwidth_bn'].'<br>';
                    echo $image_height.'>'.$data2['maxheight_bn'];
                    exit();
                    }



Successfully upload pictures
Image is too big
995>1000
229>240             

I wonder why the condition pass? It suppose to be too small instead of too big.

Edited by davy_yg

5
Contributors
5
Replies
33
Views
2 Years
Discussion Span
Last Post by Traevel
0

You're outputting two different values than the ones you're checking for.
Your if loop looks at maxwidth and maxheight but your message outputs maxwidth_btn and maxheight_btn.
So from that you can't actually be sure that the height/width fails the condition. Unless you know that maxwidth and maxwidth_btn are definitely the same value?
I'm pretty sure if you output maxwidth and maxheight one of those will be passing the IF condition.

0
if($image_width > $data2['maxwidth'] or $image_height > $data2['maxheight'])

shouldn't this be like

if($image_width > $data2['maxwidth'] || $image_height > $data2['maxheight'])
0

As hericles said, you are using 2 different variables in comparison $data2['maxwidth'] v. $data2['maxwidth_bn'] and $data2['maxheight'] v. $data2['maxheight_bn']. There is no way to check whether both your variables are the same as its counter part.

0
if($image_width > $data3['maxwidth_bn'] || $image_height > $data3['maxheight_bn'])
                    {
                    echo "Image is too big";
                    echo $image_width.'>'.$data3['maxwidth_bn'];
                    echo $image_height.'>'.$data3['maxheight_bn'];
                    exit();
                    }   

I still do not understand why it pass the condition:

Image is too big
597>1000
424>240

0
if($image_width > $data3['maxwidth_bn'] || $image_height > $data3['maxheight_bn'])

That means:
IF the image width is larger than max_width OR the image height is larger than max_height, the image is too big.

Is it too wide? 597 is not larger than 1000, so no.
Is it too high? 424 is larger than 240, so yes.

If either one is true (OR) it will be too big.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.