THE WORLD'S LARGEST WEB DEVELOPER SITE

PHP Tutorial

PHP HOME PHP Intro PHP Install PHP Syntax PHP Comments PHP Variables PHP Echo / Print PHP Data Types PHP Strings PHP Numbers PHP Constants PHP Operators PHP If...Else...Elseif PHP Switch PHP While Loops PHP For Loops PHP Functions PHP Arrays PHP Sorting Arrays PHP Superglobals

PHP Forms

PHP Form Handling PHP Form Validation PHP Form Required PHP Form URL/E-mail PHP Form Complete

PHP Advanced

PHP Arrays Multi PHP Date and Time PHP Include PHP File Handling PHP File Open/Read PHP File Create/Write PHP File Upload PHP Cookies PHP Sessions PHP Filters PHP Filters Advanced

MySQL Database

MySQL Database MySQL Connect MySQL Create DB MySQL Create Table MySQL Insert Data MySQL Get Last ID MySQL Insert Multiple MySQL Prepared MySQL Select Data MySQL Delete Data MySQL Update Data MySQL Limit Data

PHP XML

PHP XML Parsers PHP SimpleXML Parser PHP SimpleXML - Get PHP XML Expat PHP XML DOM

PHP - AJAX

AJAX Intro AJAX PHP AJAX Database AJAX XML AJAX Live Search AJAX Poll

PHP Examples

PHP Examples PHP Quiz PHP Exercises PHP Certificate

PHP Reference

PHP Overview PHP Array PHP Calendar PHP Date PHP Directory PHP Error PHP Filesystem PHP Filter PHP FTP PHP Libxml PHP Mail PHP Math PHP Misc PHP MySQLi PHP Network PHP SimpleXML PHP Stream PHP String PHP XML Parser PHP Zip PHP Timezones

PHP ftp_rawlist() Function

❮ PHP FTP Reference

Example

Get list of files with file information:

<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);

// get the file list for /
$filelist = ftp_rawlist($ftp_conn, "/");

// close connection
ftp_close($ftp_conn);

// output $filelist
var_dump($filelist);
?>

The output could look something like this:

array(3)
{
[0] => string(57) "drw-rw-rw- 1 user group 0 Jan 03 08:33 images"
[1] => string(62) "-rw-rw-rw- 1 user group 160 Feb 16 13:54 php"
[2] => string(75) "-rw-rw-rw- 1 user group 20 Feb 14 12:22 test"
}

Definition and Usage

The ftp_rawlist() function returns a list of files with file information (from a specified directory on the FTP server).

Syntax

ftp_rawlist(ftp_conn, dir, recursive);
Parameter Description
ftp_conn Required. Specifies the FTP connection to use
dir Required. Specifies the directory path. May include arguments for the LIST command. Tip: Use "." to specify the current directory
recursive Optional. By default, this function sends a "LIST" command to the server. However, if the recursive parameter is set to TRUE, it sends a "LIST -R" command



Technical Details

Return Value: An array where each element corresponds to one line of text (no parsing is performed). Returns FALSE on failure
PHP Version: 4+
PHP Changelog: The recursive parameter was added in PHP 4.3

❮ PHP FTP Reference