PHP
  Home arrow PHP arrow Page 4 - File Version Management in PHP
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

File Version Management in PHP
By: Murali Dharan
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 40
    2003-12-08

    Table of Contents:
  • File Version Management in PHP
  • Program Plan
  • Let's Build It
  • Let's Build It, Cont'd.
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th -1:00PM EST. Register Today!

    File Version Management in PHP - Let's Build It, Cont'd.


    (Page 4 of 5 )

    The Main Program:

    When you execute file_upload_manager.php, the following code is executed first and the other functions described above are called in the middle of the program.

    Once the user selects the file and clicks upload, the main program part is executed. Here the program gets the upload file information like file size, file type, date modified and time stamp.

    Next it checks for the file existence in the destination folder.  If the file is present the “if” part of the program gets executed, otherwise the file is copied to the destination folder and the file information is inserted in the database.

    If the file exists, and if the file size and/or time stamp differs, Get_New_File_Name() function is called to generate a new file name. Then the file is copied to the destination folder and the file information is stored in the database.

    If the file exists and the user had checked the “Replace Existing File” option, the file is replaced and the file information is updated in the database accordingly. Otherwise, the user is redirected to the file_display_manager.php page and the message “A previous version of this file exists” is displayed.

    File Display Manager:

    This PHP script handles the displaying of files present in the folder. As described in the plan, the program will display the file name, size, type and an option to delete the file.

    dir_display() Function:

    This function displays the files available in the folder in a table. The template looks like this:

    FileSizeTypeModified 
    abc.doc25 KbdocOct 01, 2003Delete
    xyz.txt24 BytestxtOct 03, 2003Delete
    abc.doc48 KbdocOct 05, 2003Delete
    abc.doc67 KbdocNov 05, 2003Delete
    xyz.txt58 BytestxtOct 23, 2003Delete

    You can see that the file names are repeated. But you can see the file size and date modified differs. To view / download the file, you can click the hyperlink of the file name.  This will show you the file name of the different version. You can customize the program to include another field “Version” to track the file version.

    To delete a file, click on the ‘Delete’ hyperlink, which will prompt for confirmation.

    More PHP Articles
    More By Murali Dharan


     

    PHP ARTICLES

    - Making Usage Statistics in PHP
    - Installing PHP under Windows: Further Config...
    - File Version Management in PHP
    - Statistical View of Data in a Clustered Bar ...
    - Creating a Multi-File Upload Script in PHP
    - Executing Microsoft SQL Server Stored Proced...
    - Code 10x More Efficiently Using Data Access ...
    - A Few Tips for Speeding Up PHP Code
    - The Modular Web Page
    - Quick E-Commerce with PHP and PayPal
    - Regression Testing With JMeter
    - Building an Iterator with PHP
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway