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? 
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

    - 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
    - Method Chaining: Adding More Methods to the ...
    - Method Chaining in PHP 5
    - The Role of Interfaces in Applying the Depen...
    - Dependency Injection: Using a Setter Method ...
    - Using a Model Class with the Dependency Inje...
    - Injecting Objects Using Setter Methods with ...
    - Injecting Objects by Constructor with the De...
    - The Dependency Injection Design Pattern in P...
    - Performing Inferential Statistical Analysis ...
    - Performing Descriptive Statistical Analysis ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    Stay green...Green IT