PHP ftp_rawlist() Function

Definition and Usage

The ftp_rawlist() function returns a detailed list of files in the specified directory.

Syntax

ftp_rawlist(ftp_connection,dir,recursive)
Parameter Description
ftp_connection Required. Specifies the FTP connection to be used (identifier for the FTP connection).
dir Required. Specifies the directory. Use "." to specify the current directory.
recursive Optional. By default, the function sends the "LIST" command to the server. If the recursive parameter is set to true, it sends the "LIST -R" command.

Description

The ftp_rawlist() function will execute the FTP LIST command and return the result as an array. Each element of the array is a line of the returned text, and the output structure will not be parsed.

Use Function ftp_systype() Can be used to determine the type of FTP server, thereby determining the type of the returned list.

Example

<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");
print_r (ftp_rawlist($conn,"."));
ftp_close($conn);
?>

Output similar to:

Array 
( 
[0] => dr--r--r-- 1 user group 0 Feb 15 13:02 .
[1] => dr--r--r-- 1 user group 0 Feb 15 13:02 ..
[2] => drw-rw-rw- 1 user group 0 Jan 03 08:33 images
[3] => -rw-rw-rw- 1 user group 160 Feb 16 13:54 test.php
[4] => -rw-rw-rw- 1 user group 20 Feb 14 12:22 test.txt
)