PHP 8.1.0 RC 5 available for testing

ftp_mlsd

(PHP 7 >= 7.2.0, PHP 8)

ftp_mlsdReturns a list of files in the given directory

Descripción

ftp_mlsd(FTP\Connection $ftp, string $directory): array|false

Parámetros

ftp

An FTP\Connection instance.

directory

The directory to be listed.

Valores devueltos

Returns an array of arrays with file infos from the specified directory on success or false on error.

Historial de cambios

Versión Descripción
8.1.0 The ftp parameter expects an FTP\Connection instance now; previously, a recurso was expected.

Ejemplos

Ejemplo #1 ftp_mlsd() example

<?php

// set up basic connection
$ftp ftp_connect($ftp_server);

// login with username and password
$login_result ftp_login($ftp$ftp_user_name$ftp_user_pass);

// get contents of the current directory
$contents ftp_mlsd($ftp".");

// output $contents
var_dump($contents);

?>

El resultado del ejemplo sería algo similar a:

array(5) {
  [0]=>
  array(8) {
    ["name"]=>
    string(1) "."
    ["modify"]=>
    string(14) "20171212154511"
    ["perm"]=>
    string(7) "flcdmpe"
    ["type"]=>
    string(4) "cdir"
    ["unique"]=>
    string(11) "811U5740002"
    ["UNIX.group"]=>
    string(2) "33"
    ["UNIX.mode"]=>
    string(4) "0755"
    ["UNIX.owner"]=>
    string(2) "33"
  }
  [1]=>
  array(8) {
    ["name"]=>
    string(2) ".."
    ["modify"]=>
    string(14) "20171212154511"
    ["perm"]=>
    string(7) "flcdmpe"
    ["type"]=>
    string(4) "pdir"
    ["unique"]=>
    string(11) "811U5740002"
    ["UNIX.group"]=>
    string(2) "33"
    ["UNIX.mode"]=>
    string(4) "0755"
    ["UNIX.owner"]=>
    string(2) "33"
  }
  [2]=>
  array(8) {
    ["name"]=>
    string(11) "public_html"
    ["modify"]=>
    string(14) "20171211171525"
    ["perm"]=>
    string(7) "flcdmpe"
    ["type"]=>
    string(3) "dir"
    ["unique"]=>
    string(11) "811U5740525"
    ["UNIX.group"]=>
    string(2) "33"
    ["UNIX.mode"]=>
    string(4) "0755"
    ["UNIX.owner"]=>
    string(2) "33"
  }
  [3]=>
  array(8) {
    ["name"]=>
    string(10) "public_ftp"
    ["modify"]=>
    string(14) "20171211174536"
    ["perm"]=>
    string(7) "flcdmpe"
    ["type"]=>
    string(3) "dir"
    ["unique"]=>
    string(11) "811U57405EE"
    ["UNIX.group"]=>
    string(2) "33"
    ["UNIX.mode"]=>
    string(4) "0755"
    ["UNIX.owner"]=>
    string(2) "33"
  }
  [4]=>
  array(8) {
    ["name"]=>
    string(3) "www"
    ["modify"]=>
    string(14) "www"
    ["perm"]=>
    string(7) "flcdmpe"
    ["type"]=>
    string(3) "dir"
    ["unique"]=>
    string(11) "811U5740780"
    ["UNIX.group"]=>
    string(2) "33"
    ["UNIX.mode"]=>
    string(4) "0755"
    ["UNIX.owner"]=>
    string(2) "33"
  }
}

Ver también

  • ftp_rawlist() - Devuelve una lista detallada de archivos en el directorio especificado
  • ftp_nlist() - Devuelve una lista de los archivos que se encuentran en el directorio especificado

add a note add a note

User Contributed Notes 1 note

up
0
fantastory dot net at gmail dot com
8 months ago
When running from script the function may require ftp_pasv, for swithching server to pasive mode.

If you are behind firewall ftp_mlsd will return FALSE otherwise.
To Top