I used the ftp_* functions for ftp, in place of curl, because curl tried to change directories, but its not allowed on this ftp server, so the code i used is; $local_file...
See RFC 1738 and FTP URLs. As for the output location, just give a path to -o. Security suggestions: Don't put your password in the URL. Storing it in ~/.netrc is not particularly secure either, but it at least is hidden from ps -ef. Your password is sent in clear text. If the server supports it, use curl...