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  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Moblin 
JMSL Numerical Library 
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

Stream Me Up, Scotty! (part 1)
By: Vikram Vaswani, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 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:
      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
     
     
    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

    - Validating Web Forms with the Code Igniter P...
    - Output Buffering
    - Paginating Database Records with the Code Ig...
    - HTTP Headers in Web Development
    - Project Management: Administration
    - Building a Database-Driven Application with ...
    - User Authentication for a Project Management...
    - Introduction to the CodeIgniter PHP Framework
    - Adding Users for a Project Management Applic...
    - Migrating Class Code for a MIME Email to PHP...
    - Login and Logout Authentication for a Projec...
    - Composing Messages in HTML for MIME Email wi...
    - Project Management: Authentication
    - A Better Way to Determine MIME Types for MIM...
    - Project Management Overview





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