One day I need to display filesize after upload the file then I have searched on Google and get a function from manual but during max file upload it display error so its a simple define functions for max execution time and max filesize on top then this will work great.
Here is the code may be it can help for somebody.
@ini_set( 'upload_max_size' , '100M' );
@ini_set( 'post_max_size', '100M');
@ini_set( 'max_execution_time', '600' );
function display_filesize($filesize){
if(is_numeric($filesize)){
$decr = 1024; $step = 0;
$prefix = array('Byte','KB','MB','GB','TB','PB');
while(($filesize / $decr) > 0.9){
$filesize = $filesize / $decr;
$step++;
}
return round($filesize,2).' '.$prefix[$step];
} else {
return 'NaN';
}
}
Cheers ! enjoy the code.