[英]how to Move file from local to sftp folder in Laraver with filesystem?
i want to move file from my local to another server using sftp, here is my sftp setting in config/filesystem.php 我想使用sftp将文件从本地移动到另一台服务器,这是config / filesystem.php中的sftp设置
'sftp' => [
'driver' => 'sftp',
'host' => '192.xxx.0.xxx',
'port' => 22,
'username' => 'xxx',
'password' => 'xxx',
'root' => '/',
'timeout' => 10,
],
and here is my code in controller 这是我在控制器中的代码
$file_local = public_path().'/documents/1.pdf';
$file_sftp = Storage::disk('sftp')->put('1.pdf', $file_local);
$move = File::move($file_local, $file_ftp);
but in the sftp folder, the file is exist but corrupted, please need your help 但是在sftp文件夹中,该文件存在但已损坏,请需要您的帮助
777 permission! 777许可! is the key entrance for evilness! 是邪恶的关键入口! I ldn't configure my apps that way! 我没有以这种方式配置我的应用程序! I would check first if the file still exists in the storage folder ( the file you are renaming ). 我将首先检查文件是否仍存在于存储文件夹(您正在重命名的文件)中。 My second assumption - the file is owned by a completely different user? 我的第二个假设-文件由完全不同的用户拥有? Normally the entire project should be under one user.group owner! 通常,整个项目应在一个user.group所有者的控制下! It might be apache.groupName in your case but you should double check. 在您的情况下,可能是apache.groupName,但您应仔细检查。 So I would do 所以我会做
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
If not, I would save it else where other than the storage folder. 如果没有,我会将其保存到除存储文件夹以外的其他位置。 Hope this help you 希望这对您有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.