PHP
  Home arrow PHP arrow Page 3 - 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) - ...In With The New


    (Page 3 of 9 )

    Initiating an FTP connection in PHP follows the same basic principles: open an FTP connection, send authentication information, and then use built-in PHP functions to navigate through directories or transfer files. Let's take a look at the PHP version of the session you just saw.

    <? // connect to FTP server $conn = ftp_connect("ftp.server.com"); // log in with username and password ftp_login($conn, "john", "doe"); // get remote system type ftp_systype($conn); // obtain file listing $filelist = ftp_nlist($conn, "."); // download file ftp_get($conn, "data.zip", "data.zip", FTP_BINARY); // close connection ftp_quit($conn); ?>
    Let's go through this step by step:

    In order to initiate an FTP connection, PHP offers the ftp_connect() function, which takes a host name and port number as parameters. In the example above, the host name is "ftp.server.com"; since a port is not specified, PHP will attempt a connection to the default FTP port, 21.

    The ftp_connect() function returns a handle for the FTP connection if successful; this handle is used by all subsequent FTP functions.

    <? // connect to FTP server $conn = ftp_connect("ftp.server.com"); ?>
    Once connected, the ftp_login() function is used to send the FTP server a user name and password. As you can see, ftp_login() also uses the handle returned by ftp_connect() to ensure that the authentication information is transmitted to the correct server.

    <? // log in with username and password ftp_login($conn, "john", "doe"); ?>
    At this point, you can begin playing with some of the other functions available to you, specifically those that provide you with system information and directory listing (they're covered in detail on the next page).

    Once you're finished, it's important that you remember to close your FTP session with ftp_quit().

    <? // close connection ftp_quit($conn); ?>


    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 1 hosted by Hostway