Home arrow PHP arrow Page 6 - Stream Me Up, Scotty! (part 1)

Start Me Up! - PHP

PHP4 comes with a bunch of new functions designed to allow FTPconnections over the Web. This article explores the new FTP functions,together with an example of how they can be used to build a browser-basedFTP client.

  1. Stream Me Up, Scotty! (part 1)
  2. Out With The Old...
  3. ...In With The New
  4. Where Am I?
  5. GETting It Right
  6. Start Me Up!
  7. Lights! Camera! Action!
  8. Well-Formed Ideas
  9. Appendix: Code Listing
By: Vikram Vaswani, (c) Melonfire
Rating: starstarstarstarstar / 4
November 07, 2000

print this article


Now, that covers the various FTP functions that PHP provides - but, just by itself, it isn't enough. The true power of these functions becomes visible only when they're combined into a single application which provides file transfer and file management capabilities. Since we're talking about FTP functions, it seems obvious that the best application for such a demonstration would be a Web-based FTP client - which is exactly what's coming up next!

Before we get into a code listing, I should make it clear that the example below is meant only to illustrate the various functions you've just learned. While it is functional and can be used as a "real" FTP client, I've omitted many basic error checking routines to make it easier to explain, and you should consider this use-at-your-own-risk software if you decide to implement it in a live environment. And cigarette smoking causes cancer. You have been warned.

The application code is separated across three different files:

index.html - the log in screen

actions.php4 - the code for all FTP transactions

include.php4 - the main interface, which displays file listings and control buttons

A complete code listing (with comments) is available at the end of the article - I'll simply be highlighting the important areas here.

Let's begin at the top, with "index.html":

<table border=0 align=center> <form action="actions.php4" method=post> <input type=hidden name=action value=CWD> <tr> <td> Server </td> <td> <input type=text name=server> </td> </tr> <tr> <td> User </td> <td> <input type=text name=username> </td> </tr> <tr> <td> Password </td> <td> <input type=password name=password> </td> </tr> <tr> <td colspan=2 align=center> <input type="submit" value="Beam Me Up, Scotty!"> </td> </tr> </form> </table>
This is the log-in form, with fields for the FTP server name, the FTP user name and the password; these are stored in the variables $server, $username and $password respectively. Once the form is submitted, it calls the PHP script "actions.php4", which then takes over to initiate the FTP connection.

Note the hidden field, which sends the directive "action=CWD" to "actions.php4" - you'll see what role this plays on the next page.

This article copyright Melonfire 2000. All rights reserved.

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

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates


Dev Shed Tutorial Topics: