#native_company# #native_desc#

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.



function File_Size($size)


$size 104876){

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

        } elseif(
$size 1024){

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

        } else {

$return_size=$size." Bytes";