Jump to content

calcul error


Matpatnik

Recommended Posts

Hi guys,I have this little variable that doesn't show up:

$i_size = round($_FILES['image_filename']['size'] / 1024);

I'm trying to echo the $i_size it doesn't work, I tried to echo $i_size without the round() nothing show up and when I echo $_FILES['image_filename']['size'] alone it work!it used to work to control the file size uploadedthank you

Link to comment
Share on other sites

now that's weird with this code:

// make sure no one upload over the maximum sizeif ($i_size > $a_maxsize) {	include "include/header.php";	echo "The " . $i_temp . " size is " . $i_size . " kb but the maximum upload size is " . $a_maxsize ." kb.<br>" .		 "Your image is too big by " . ($i_size - $a_maxsize) . " kb. Please reduce the size of that image and try again.";	getfooter($ect);

I got this output!

The Water lilies.jpg size is 82 kb but the maximum upload size is 100 kb.Your image is too big by -18 kb. Please reduce the size of that image and try again.
I don't know what to think about this because it does the calculation now but doesn't respect the if statement!Both variable in the if statement are fine and work properly as it show in the output but it's not supose to echo that because it's smaller so it should skip that part. I don't know if the fact that $a_maxsize is comming from the database change something?Out of subject I got this error very often went going on your site
 The server closed the connection while reading the response. Contact your system administrator.
Link to comment
Share on other sites

It doesn't do anthing special only the same message:

The Water lilies.jpg size is 82 kb but the maximum upload size is 100 kb.Your image is too big by -18 kb. Please reduce the size of that image and try again.
Link to comment
Share on other sites

Then the IF statement is not being executed for some reason. Is that the exact code you pasted above, did you remove anything from it? Because that code will do exactly what it says - if $i_size is greater then $a_maxsize, then it will display the message. If you are seeing the message display, and $i_size is not greater then $a_maxsize, then the IF condition is not being checked.

Link to comment
Share on other sites

here this is from the server:

$i_temp = $_FILES['image_filename']['name'];$i_size = round($_FILES['image_filename']['size'] / 1024);	// make sure no one upload over the maximum sizeif (floatval($i_size) > floatval($a_maxsize)) {	include "include/header.php";	echo "The " . $i_temp . " size is " . $i_size . " kb but the maximum upload size is " . $a_maxsize ." kb.<br>" .		 "Your image is too big by " . ($i_size - $a_maxsize) . " kb. Please reduce the size of that image and try again.";	getfooter($connect);} else {

It's the first statement after the users validation

Link to comment
Share on other sites

You probably mean this: :)

echo "<pre>";echo $i_size . "\n";var_dump($i_size);echo "\n" . $a_maxsize . "\n";var_dump($a_maxsize);echo "</pre>";

I figured that you did it very quickly :)there is the result

82float(82)NULLWater lilies.jpg
Why $a_maxsize doesn't appear in the if statement and appear few line after? Edited by Matpatnik
Link to comment
Share on other sites

I meant what I wrote, it would have printed the variable names. According to the output, $a_maxsize is null. Anything is greater then a null value. Since the value of $a_maxsize gets printed 2 lines later, chances are that you define it in the included file.

Link to comment
Share on other sites

true it's define just after the validation, is there a way to bypass this or I will have to write the function that define the $a_maxsize in every page? because in that function $a_maxsize is a global variable.edited: I changed where the function was called and it seems to be ok now.Thank you

Link to comment
Share on other sites

I do the same but I only do that for variable and function that might be reused in other page. All other variable and function stay in there own page.I'm still looking on how to set the structure of the site and I'm getting closer every time :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...