PHP
  Home arrow PHP arrow Page 4 - 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) - Where Am I?


    (Page 4 of 9 )

    Once logged in to an FTP server, PHP offers a number of functions that can provide system-specific information, together with file and directory information.

    First, the ftp_pwd() function comes in very useful if you need to find out where you're currently located in the directory tree.

    <? // get current location $here = ftp_pwd($conn); ?>
    In case you need to know the operating system that the FTP server is currently running, ftp_systype() will be able to give you this information.

    <? // get system type $server_os = ftp_systype($conn); ?>
    In case you need to switch passive (PASV) mode on or off, PHP has the ftp_pasv() function, which acts as a toggle switch, turning PASV mode on and off. In case you don't know what passive mode...don't worry about it!

    <? // turn PASV on ftp_pasv($conn, 1); ?>
    How about a file listing? Well, PHP offers two types of listings - a compact listing containing only file and directory names, and a long listing containing detailed information on file sizes, permissions and timestamps.

    The first listing is provided by the ftp_nlist() function, while the second comes via ftp_rawlist(). Both functions require a directory name to be passed as a parameter, and both return the listing as an array. Each element of this array corresponds to one line of text from the listing.

    <? // obtain file listing $filelist = ftp_nlist($conn, "."); ?>
    And in case you're curious about file sizes, there's a very handy ftp_size() function which returns the size of the specified file in bytes. An important point to be noted here is that this function returns a value of -1 on error - a fact which comes in handy if you're trying to distinguish between files and directories, since this function, when invoked on a directory, typically returns a value of -1. You'll see this technique being used extensively in the example coming up later.

    <? // obtain file size of file "data.zip" $filelist = ftp_size($conn, "data.zip"); ?>


    This article copyright Melonfire 2000. All rights reserved.

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


     

       

    PHP ARTICLES

    - 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
    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application





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