dongzhang8475 2018-12-06 08:00
浏览 245

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

i want to move file from my local to another server using sftp, here is my sftp setting in config/filesystem.php

'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);

i got this error enter image description here

but in the sftp folder, the file is exist but corrupted, please need your help enter image description here

  • 写回答

1条回答 默认 最新

  • douju2331 2018-12-06 08:05
    关注

    777 permission! 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! It might be apache.groupName in your case but you should double check. 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

    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示