使用文件系统 Laravel 上传文件 FTP



>我尝试将 excel 文件上传到我的 ftp 但得到

ftp_fput((: 无法打开文件进行写入。

我的文件存储在:存储/应用程序

与ftp的连接工作正常! 我测试

$file = '测试.txt'

它正在工作 文件已上传到FTP。 但是当我尝试存储 Excel 文件时,它不起作用。 希望有人可以帮助我。 提前非常感谢

这是我的代码:

$file = Excel::create('' . $date . '' , function($excel) use ($licencies) {
        $excel->sheet('Excel', function($sheet) use ($licencies)
        {
            $sheet->fromArray($licencies);
        });
    });
    $ftp = IlluminateSupportFacadesStorage::createFtpDriver([
        'host'     => '....',
        'username' => '....',
        'password' => '....',
        'port'     => '..',
        'timeout'  => '..',
        'root' => '/...',
    ]);
    $ftp->put($file->store("xlsx", false, true)['full'], 'upload');

首先,检查您的FTP用户是否有权将文件上传到FTP服务器/目录。

您可能首先需要通过以下方式在本地存储 excel 文件:

$file->store("xlsx", false, true);

然后打电话:

$ftp->put( $date . '.xlsx', 'upload');

然后,您可以删除本地创建的文件。

最新更新