Modifying file size

Discussion in 'PHP' started by Kuna, Aug 24, 2010.

  1. #1
    I need to modify free script. THis is how script showing file size.
                        
    $size = urlfilesize($extern_file);
    $a = array("B", "KB", "MB", "GB", "TB", "PB");
    $pos = 0;
    while ($size >= 1024) {
    $size /= 1024;
    $pos++;
    }
    $size = round($size,2)." ".$a[$pos];
    
    PHP:
    When I upload file which is e.g.5kb it shows 5kb, when I upload 5mb, it shows 5mb, I would like to make it to show 5000kb
     
    Kuna, Aug 24, 2010 IP
  2. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #2
    
    $size = urlfilesize($extern_file); //assuming this is returned in bytes...
    $size /= pow(2,10).' KB';
    
    PHP:
     
    danx10, Aug 24, 2010 IP