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

AtomCoder's avatar

FTP - Verify Credentials

Hi,

I'm trying to periodically verify that a configured FTP server within my filesystem is accessible and operational.

How can I test a FTP account to check if the credentials are correct and valid? (without uploading a file)

0 likes
4 replies
martinbean's avatar

@atomcoder Use PHP’s native ftp_connect function and see if you can instantiate a connection with the credentials you’re given. If you can, they’re valid.

1 like
kaplay's avatar
kaplay
Best Answer
Level 33

Hi,

You can try to access the files Storage::disk('ftp')->files(). If it returns an array object (empty or full), it means the connection is successful. Otherwise, there is a problem. And maybe you have to control the 'throw' => true|false situation in your config file, when you try something like that.

1 like

Please or to participate in this conversation.