Answer the question
In order to leave comments, you need to log in
How to scan a directory in php via sftp?
I need to fully scan a folder and all its subfolders for *.cfg files and output the path and file name together in an array, for example:
cfg/motd.cfg
server/perm.cfg
Google doesn't help or I can't find it.
It is necessary through SFTP, because RSA keys are used for authorization on the server.
Answer the question
In order to leave comments, you need to log in
Documentation
php.net/manual/ru/function.ssh2-sftp.php Connection
class example
https://phptime.ru/php-features/ispolzovanie-ssh-i...
Getting a list of files
stackoverflow.com/questions/8840883 /how-to-list-fi...
You can install this library via Composer:
https://github.com/hugsbrugs/php-sftp
- and work through it, for example:
require_once dirname(__DIR__).'/vendor/autoload.php';
use Hug\Sftp\Sftp as Sftp;
print_r(Sftp::scandir($server, $user, $password, '/home/a/agnevy6d', $port = 22, $timeout = 10));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question