繁体   English   中英

如何使用文件系统将文件从本地移动到Laraver中的sftp文件夹?

[英]how to Move file from local to sftp folder in Laraver with filesystem?

我想使用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文件夹中,该文件存在但已损坏,请需要您的帮助 在此处输入图片说明

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM