Laravel将文件发送到FTP,同时指定用户名和密码



因此,我制作了一个脚本来生成需要转到特定FTP位置的提要。 我已经有了我的提要表的凭据,但是我如何让laravel使用这些凭据而不是.env文件中的默认凭据?

这就是我所拥有的,对于一个确定的位置来说很好。

$file_ftp = Storage::disk('ftp')->put('{{ $feed->filename }}', $feedData);

只是想知道是否有办法覆盖内联的ftp凭据。

好的,所以这是我自己问题的答案:

$config = [
'host' => 'ftp.server.com',
'username' => 'username',
'password' => 'password',
'ssl' => 'true',
'passive' => 'true',
'root' => '/',
'timeout' => 30,
'ignorePassiveAddress' => 'false'
];
$fs = new Filesystem(new Ftp($config));
//Upload to FTP location
$fs->put($feed->filename, Storage::get('/storage/' . $feed->filename));

最新更新