[英]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);
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.