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
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]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.