PHP
  Home arrow PHP arrow Page 4 - File Management with PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
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? 
Google.com  
PHP

File Management with PHP
By: Murali Dharan.M
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 75
    2004-03-29


    Table of Contents:
  • File Management with PHP
  • Building the Database
  • File_Size() and Display_form Functions
  • The Main Program

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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

     
     
    ADVERTISEMENT


    File Management with PHP - The Main Program
    ( Page 4 of 4 )

    When you execute file_upload_manager.php, the 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:

    File Manager

    Size

    Type Modified
    abc.doc 25 Kb doc Oct 01, 2003 Delete
    xyz.txt 24 bytes txt Oct 03, 2003 Delete
    abc.doc 48 Kb doc Oct 05, 2003 Delete
    abc.doc 67 Kb doc Nov 05, 2003 Delete
    xyz.txt 58 bytes txt Oct 23, 2003 Delete


    You can see that the file names are repeated, but you can see the file size and date modified differs. To view and/or 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.

    I welcome your comments and suggestions!



     
     
    >>> More PHP Articles          >>> More By Murali Dharan.M
     

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek