【问题标题】:how to Move file from local to sftp folder in Laraver with filesystem?如何使用文件系统将文件从本地移动到 Laravel 中的 sftp 文件夹?
【发布时间】:2018-12-06 08:00:59
【问题描述】:

我想使用 sftp 将文件从本地移动到另一台服务器,这是我在 config/filesystem.php 中的 sftp 设置

'sftp' => [
        'driver' => 'sftp',
        'host' => '192.xxx.0.xxx',
        'port' => 22,
        'username' => 'xxx',
        'password' => 'xxx',
        'root' => '/',
        'timeout' => 10,
    ],

这是我在控制器中的代码

 $file_local = public_path().'/documents/1.pdf';
 $file_sftp = Storage::disk('sftp')->put('1.pdf', $file_local);
 $move = File::move($file_local, $file_ftp);

我收到了这个错误

但在sftp文件夹中,文件存在但已损坏,请您帮忙

【问题讨论】:

    标签: php laravel filesystems sftp move


    【解决方案1】:

    777 许可!是邪恶的关键入口!我不会那样配置我的应用程序!我会先检查该文件是否仍然存在于存储文件夹中(您正在重命名的文件)。我的第二个假设 - 该文件由完全不同的用户拥有?通常整个项目应该在一个 user.group 所有者之下!在您的情况下可能是 apache.groupName 但您应该仔细检查。所以我会这样做

    ls -la  // in project root directory and grab the ownerUser and ownerGroup names 
    // then I ld make sure everything is owned by them - back up your project first before changing ownership!
    sudo chown  -R ownerUser.ownerGroup *   // -R for recursive
    

    如果没有,我会将其保存在存储文件夹以外的其他位置。希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2015-03-25
      • 1970-01-01
      • 1970-01-01
      • 2016-04-11
      • 2019-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      相关资源
      最近更新 更多