PHPBuilder - File Version Management in PHP Page 4



RSS Twitter
Articles Php Functions

File Version Management in PHP - Page 4

by: M. Murali Dharan
|
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";
        }

    }
?>

 

« Previous Page
1
|
2
|
3
|
4
|
5
|
6
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
M. Murali Dharan

Comment:



Comment:

(Maximum characters: 1200). You have characters left.