Jump to content

Getting the correct value?


Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/2534-getting-the-correct-value/
Share on other sites

 

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.

296985[/snapback]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.