Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AO's avatar
Level 1

Get all files from directories

Hello.

I'm using FTP in my app.

I'm trying to fetch all the files inside all the folders in my FTP server.

for example :

FOLDER 1
  FILE 1
  FILE2 
FOLDER 2
 FILE 1 
 FILE 2

I can get all the directories by using :

Storage::disk('ftp')->directories();

is it possible? Thanks.

0 likes
1 reply
Nakov's avatar

Well, no, it is not possible that way, because the storage is a Laravel directory, and in your case it expects that you have storage/public/ftp directory for example, and it will list all the directories within that directory, but not everything on the FTP server.

Take a look at this:

https://www.php.net/manual/en/function.ftp-nlist.php

And the first example there. So you will need to make a connection to the server, and then list all the folders/files there.

1 like

Please or to participate in this conversation.