crzyman Posted September 19, 2005 Share Posted September 19, 2005 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 More sharing options...
crzyman Posted September 19, 2005 Author Share Posted September 19, 2005 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 https://forums.phpfreaks.com/topic/2534-getting-the-correct-value/#findComment-8401 Share on other sites More sharing options...
marker5a Posted September 19, 2005 Share Posted September 19, 2005 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 Link to comment https://forums.phpfreaks.com/topic/2534-getting-the-correct-value/#findComment-8412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.