Jump to content


Photo

Getting the correct value?


  • Please log in to reply
2 replies to this topic

#1 crzyman

crzyman
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 19 September 2005 - 02:43 PM

I have this code:
$max=15728640.00;
$test = $filesize+$dirsize;

if ($test > $max) {
$errormsg = "Total file size is greater than the total limit (".getfilesize($max).").";
return;
}


$filesize is the size of a file about to be uploaded. $dirsize is the size of the directory in which the file is to be uploaded into. $test is the file to be uploaded plus the directory size. Now I am trying to set a limit on the size of the folder in which visitors to my site can upload into. I want that size limit to be 15 MiB.
I have tried to do $max = 15 * pow(1024,2); , but that doesn't work (still not sure why?).
I try to use $max=15728640 (1.53 MiB right?), but that will not work.
Now I tried to use $max=1572864; Then I get: Total file size is greater than the total limit (1.5 MiB).
So why when I use $max=15728640 does it allow the file to be upload? I have 40 MiB in the upload folder. Can anyone sort this out for me? I am very confused.

#2 crzyman

crzyman
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 19 September 2005 - 02:53 PM


Posted this in the wrong forum. Sorry.


I have this code:
$max=15728640.00;
$test = $filesize+$dirsize;

        if ($test > $max) {
                $errormsg = "Total file size is greater than the total limit (".getfilesize($max).").";
  return;
}
$filesize is the size of a file about to be uploaded. $dirsize is the size of the directory in which the file is to be uploaded into. $test is the file to be uploaded plus the directory size. Now I am trying to set a limit on the size of the folder in which visitors to my site can upload into. I want that size limit to be 15 MiB.
I have tried to do $max = 15 * pow(1024,2); , but that doesn't work (still not sure why?).
I try to use $max=15728640 (1.53 MiB right?), but that will not work.
Now I tried to use $max=1572864; Then I get: Total file size is greater than the total limit (1.5 MiB).
So why when I use $max=15728640 does it allow the file to be upload? I have 40 MiB in the upload folder. Can anyone sort this out for me? I am very confused.

View Post



#3 marker5a

marker5a
  • Members
  • PipPipPip
  • Advanced Member
  • 30 posts

Posted 19 September 2005 - 05:24 PM

Not sure, but give this a shot.

$max='15728640.00';

Before, the decimal was not acting as a decimal, but instead as 1572864000

Give that a shot and let us know

Chris




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users