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

115
December 07, 2018, at 08:30 AM

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

but in the sftp folder, the file is exist but corrupted, please need your help

Answer 1

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

READ ALSO
Traversing in php with mysql

Traversing in php with mysql

enter image description here

169
AWS SQS message not receive auto

AWS SQS message not receive auto

I am working on aws sqs, send message is successfully but not received message not getting automatically

145
Polylang Language Detection redirect with 301

Polylang Language Detection redirect with 301

I am using polylang plugin for wordpress multi language siteAs per SEO guidelines, home page www

259