Hey guys,
I'm writing a webpage that has upload capabilities. However, i'm trying to restrict each user's total amount they are allowed to upload. I have decided that the best way is to have a database column with a max limit. Then when they log on or try to upload something, the code will check their total filesize with the databases max and either allow or deny certain functions. However, im having trouble understanding parsed file sizes.
at this point, i can grab the total size of all the files in a certain directory and i hvae it storage as $size. then i put it into a session variable. However, the number that the code spits out is like a 5 digit unparsed number. I then use parse_file_size() and it makes the code into the pretty 7.00 MB . However, when doing arithmetic operations, the 7.00 is what it uses. So what if i were to have someone upload a GB? that would be 1.00 GB and the code would allow if i checked if it was greater that 7.00 MB because the number is smaller.
So my question is this. Is there any way to understand what the parsed number means so that i can use it to do arithmatic operations, or is there like different operations so that i can check the GB vs MB?
Or, am i totally going about this the wrong way?
here is the number unparsed : 8373452
and here it is after passing through parse_file_size() : 7.99 MB
Thanks
Parsing and unparsing file sizes
Moderator: General Moderators
just use the byte information
just is the number of bytes (the long number) for everything
The MB stuff should be for user display only
The MB stuff should be for user display only