#native_company# #native_desc#
#native_cta#

File Version Management in PHP Page 4

By M. Murali Dharan
on January 14, 2004

The sql query in the beginning of the function will fetch the file names of previous versions.
If the sql query returns record sets, it means the file has previous versions. The while loop is executed to store version number generated, and the value obtained is stored in $Last_Version. Otherwise the new file name will be generated as file-name_VERSION1.

Next, if statement checks for $Last_Version != 0, if true, $Last_Version is incremented by 1 and new file name is assigned.
The return statement will return a new file name generated to the called statement.

File_Size() Function

This function returns the file size in terms of Bytes, Kb or Mb.


      

<?php

    
function File_Size($size)

    {

        if(
$size 104876){

            return 
$return_size=sprintf("%01.2f",$size 104876)." Mb";

        } elseif(
$size 1024){

            return 
$return_size=sprintf("%01.2f",$size 1024)." Kb";

        } else {

            return 
$return_size=$size." Bytes";

        }

    }

?>