PHP
  Home arrow PHP arrow Page 8 - Stream Me Up, Scotty! (part 1)
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

Stream Me Up, Scotty! (part 1)
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 4
    2000-11-07


    Table of Contents:
  • Stream Me Up, Scotty! (part 1)
  • Out With The Old...
  • ...In With The New
  • Where Am I?
  • GETting It Right
  • Start Me Up!
  • Lights! Camera! Action!
  • Well-Formed Ideas
  • Appendix: Code Listing

  • 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


    Stream Me Up, Scotty! (part 1) - Well-Formed Ideas
    ( Page 8 of 9 )

    Let's now take a quick look at the third file, "include.php4", which sets up the user interface for the application.

    "include.php4" contains three forms, together with some PHP code that takes the current list of files and separates it into three arrays:
    $files (whichcontains a list of only the files in the current directory,
    $file_sizes (which contains a list of the corresponding file sizes),
    and $dirs (which contains a list of sub-directories)

    The first of these uses the $dirs array to generate a drop-down list of available directories, and is linked to "action=CWD".

    The second uses the $files and $file_sizes to create a list of available files, with a checkbox for each. This form is linked to "action=Delete" and "action=Download", and will send an array of selected files to "actions.php4" for processing.

    You should note that downloaded files will appear in the directory where these scripts are running from. Since this directory is sure to be under your Web server root, it opens up a security hole, and it's therefore essential that you specify another location for the downloaded files to reside.

    The third form is used specifically to upload a file to the FTP site, and therefore must be of the form

    <form enctype="multipart/form-data" action=actions.php4 method=post> ... <input type=file name=upfile> ... </form>
    When PHP receives a file encoded in this manner, a number of variables come into existence. These variables specify the size of the file, a temporary filename and the file type, and will be covered in detail in the second part of this article. For the moment, all you need to know is that the original filename is stored in the variable $upfile_name, while the temporary name of the file, once uploaded, is stored in the variable $upfile (this name is assigned by PHP).

    Using this information, it's possible to construct the following ftp_put() statement:

    ftp_put($result, $upfile_name, $upfile, FTP_BINARY);
    Depending on whether or not the upload was successful, a message is generated and displayed the next time the page loads.

    Note that it's not very difficult to add additional functions to this application - for example, you could easily add functions to create and delete directories, or to filter out files of a specific type. And in case you're still stuck with PHP3, or prefer the HTTP method of file transfer, tune in for the second part of this article, where I'll be showing you how to perform equivalent file management tasks with a combination of PHP's file manipulation functions and HTTP file transfer.

    This article copyright Melonfire 2000. All rights reserved.

     
     
    >>> More PHP Articles          >>> More By Vikram Vaswani, (c) Melonfire
     

       

    PHP ARTICLES

    - Adding Ordering and Grouping Clauses to the ...
    - 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...





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