簡體   English   中英

如何在 SFTP 存儲中將目錄從一個位置移動到另一個位置 laravel 9

[英]How I can Move directory from one location to another in SFTP storage laravel 9

誰能幫我,我必須將文件從一個目錄移動到 SFTP 存儲上的另一個目錄。

我試過這個

$file = 新文件系統(); $moved = $file->moveDirectory($from, $to);

但是為此我需要目錄的完整路徑但是使用 sftp 以下代碼不起作用

$full_path_source = Storage::disk('sftp')->getDriver()->getAdapter()->getPathPrefix('batch_1');

奇怪的是,這非常模糊,令人驚訝的是,它在 Laravel 文檔和 API 中都找不到,但是Storage::move function 不僅適用於文件,它也適用於目錄:

Storage::move($oldDirectoryPath, $newDirectoryPath);

要獲取文件的路徑,您只需調用:

use Illuminate\Support\Facades\Storage;
 
$path = Storage::path('file.jpg');

文件路徑:如文檔中所示: https://laravel.com/docs/9.x/filesystem#file-paths

您可以使用 path 方法獲取給定文件的路徑。 如果您使用的是本地驅動程序,這將返回文件的絕對路徑。 如果您使用的是 s3 驅動程序,此方法將返回 S3 存儲桶中文件的相對路徑:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM