PHP
  Home arrow PHP arrow Page 3 - 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 - File_Size() and Display_form Functions
    ( Page 3 of 4 )

    File_Size() Function:
    This function returns the file size in terms of Bytes, Kb or Mb.

    <?
    function 
    File_Size
    ($size)
    {
        
    if($size 
    104876){
            
    return 
    $return_size=sprintf("%01.2f",$size 1048576).
     
    Mb"
    ;
        
    }elseif($size 
    1024){
            
    return 
    $return_size=sprintf("%01.2f",$size 1024)." Kb";
        
    }else{
            
    return $return_size=$size.
    Bytes"
    ;
        
    }
    }
    ? >

    Display_form() Function:
    This function is used to prompt the user to select the file from your local machine.


    <?
    function display_form
    ($errMsg){
        
    global $dir_path; ? >
     
    <
    html>
    <head><title>File 
    Manager
    </title></head>
    <body bgcolor="#E5E5E5">
    <div 
    align
    ="center">
    <h4>File Manager</h4>
     
    <? if(
    $errMsg){
    ? ><font face="verdana, helvetica" size="2" 
    color="red"><? echo $errMsg ? ></font>
    <?


    >

    <form action="<? echo $PHP_SELF; ? >"  
    enctype="multipart/form-data" 
     
    method="POST">
    <table border="1">
    <tr><th>File 
    Location
    :</th><th><input type="file" name="up_file" 
    /></th></tr>
    <tr><th 
    colspan
    ="2"><br><input type="checkbox" name="replace" 
    value="1">Replace Exiting File*</th></tr>
    <tr><th 
    colspan
    ="2"><br><input type="submit" name="upload" value="Upload 
    File !" 
    /></th></tr>
    </table>
     
    <
    br>* - Clicking this option will replace the existing 
    file
    <br><a href="file_display_manager.php">File 
    Manager
    </a>
     
    <
    br><? if ($status){ echo "Result  :".$status;  }? 
    >
     
    <
    p><br><b>Folder Location:</b><? echo $dir_path 
    >

    <br>You can change this location by editing the 
    file
    </font>
     
    </
    form>
    </div>
    </body>
    </html>
    <? } ? 
    >




     
     
    >>> 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 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek