My FTP Wrapper Class for PHP - Examples of Using the MY_FTP Class (Page 6 of 7 )
OK, so now you know the basics of what each function does. Notice that I didn’t go into too much detail about that actual code? That’s because I think that you really need to play around with it to really understand it. It shouldn’t take you more than about 1 hour to fully come to grips with the code, because I’ve included comments where appropriate.
Example #1: Getting a List of Files This example connects to Microsoft’s FTP server and grabs a list of files in the /Services/enterprise directory, outputting the filename and file size for files, and just the directory name for directories:
<?php
require_once("class.myftp.php");
$err = ""; $fileList = array(); $ftpClass = new MY_FTP;
Example #2: Getting the Contents of a File Again, this example uses Micrososft’s FTP server to grab the contents of a file called readme.txt and outputs it to the browser:
<?php
require_once("class.myftp.php");
$err = ""; $fileList = array(); $ftpClass = new MY_FTP;
Example #3: Does a File Exist? This example checks if a file called Desktop.exe exists in the /Services/enterprise directory of the Microsoft FTP server:
<?php
require_once("class.myftp.php");
$err = ""; $fileList = array(); $ftpClass = new MY_FTP;