I would like to list the files of a directory in an other server
I am connected to an other server using ssh2_connect function the connection is going well and i am able to fetch a desired file but i am not sure how the files can be listed.
Any help is appriciated!
http://www.php.net/manual/en/function.ssh2-exec.php
You give it the
ls
command, assuming it is a UNIX-based system (usually the case), otherwise the OP-specific command likedir
for Windows.In case anybody is struggling to get this to work, and you are running
PHP 5.6.28
there was a recent update that either created a requirement or introduced a bug whereintval()
must be used on each SFTP folder/file access function:You can use ssh2_sftp and opendir, like this: