SoWizardly SoWizardly - 4 months ago 84
PHP Question

Laravel 5 - Download remote file with dynamic FTP info

I can't seem to find any information about how one would download a remote file w/ Laravel 5 via FTP.

I tried using standard PHP

ftp_connect();


and I was met with this error...

Call to undefined function App\Http\Controllers\Tools\ftp_connect()


Is their a way to use this function, or is this something I should use a part of Laravel for?

I looked into using some part of Laravel for this, and most of the examples assume that you know the FTP ahead of time to update a config file somewhere...but the FTP info I use is given dynamically, so I guess I can't use that? Unless I'm supposed to use Config::set somehow?

I'm a little lost, any help is greatly appreciated!

Rai Rai
Answer

You're probably in a namespaced class, so PHP is looking for a ftp_connect() function inside that namespace (App\Http\Controllers\Tools).
To jump back to the global namespace, just add a backslash before the function:

\ftp_connect();