PHP
  Home arrow PHP arrow Page 5 - 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) - GETting It Right


    (Page 5 of 9 )

    Now that you know where you are and who's around you, it's time to start moving around in the directory tree - and the function that lets you do that is ftp_chdir(), which accepts a directory name as parameter.

    <? // change directory to "public_html" ftp_chdir($conn, "public_html"); ?>
    If all you want to do is go up to the parent directory, an alternative way of accomplishing this is the ftp_cdup() command, which transports you one level up from wherever you are currently.

    <? // go up one level in the directory tree ftp_cdup($conn); ?>
    You can also create and remove directories with ftp_mkdir() and ftp_rmdir(); note that ftp_mkdir() returns the name of the new directory if successful.

    <? // make the directory "test" ftp_mkdir($conn, "test"); // remove the directory "test" ftp_rmdir($conn, "test"); ?>
    The purpose of opening an FTP session is usually to transfer files - so let's get to that!

    Uploading a file is accomplished by means of the ftp_put() command, which requires you to specify a name for the file on the remote system, the name of the file to be uploaded, and the type of transfer. For example, if you'd like to upload the file "abc.txt" and rename it to "xyz.txt" on the remote system, the command would look something like this:

    <? // upload ftp_put($conn, "xyz.txt", "abc.txt", FTP_ASCII); ?>
    Alternatively, if you'd like to download a file, the built-in function is ftp_get(), which also needs both remote and local file names, although the order is reversed. If the file to be downloaded is named "his.zip" on the remote system and you plan to save it as "hers.zip" on the local system, the syntax would change to

    <? // download ftp_get($conn, "hers.zip", "his.zip", FTP_BINARY); ?>
    PHP defines two modes for file transfer - FTP_BINARY and FTP_ASCII - which need to be specified as they are displayed here, without quotes. Note that both ftp_get() and ftp_put() return result codes, indicating whether or not the transfer was successful.

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