PDA

View Full Version : image upload max size


Mike Soukup
11-26-2001, 01:22 AM
In the image upload page, it says the max size is 250kb. Do you really mean 250 kilo-bit, or do you mean kilo-byte? I tried to upload a pic that's 248kB and it didn't go through because it's too big.

Brandon Martus
11-26-2001, 04:21 AM
$FILESIZE=250000;

if ( filesize($source) > $FILESIZE ) {
// .. error ..
}




'filesize' returns the file size in bytes.

Mike Soukup
11-26-2001, 10:48 AM
Ok, now I know what my problem is. My 248KB file is less than 250KB but greater than 250,000B ;)

A little clarification for those who are confused. In computers, 1 kilo does not equal 1000 (10^3), it's actually 1024 (2^10). mega (2^20), giga (2^30), tera (2^40) and whatever's after that also differ from the metric prefixes. So after a quick calculation, my 248KB file is actually (248KB * (1024B / 1KB)) = 253,925B.

Mike

Nate Smith
11-26-2001, 11:29 AM
Of course, that could be corrected to a "true" 250KB by changing the code so it looks something like this...



$FILESIZE=250;

if ( (filesize($source) / 1024) > $FILESIZE ) {
// .. error ..
}