簡體   English   中英

使用 Laravel League s3 上傳文件時如何允許雙正斜杠

[英]How to allow double forward slashes when upload file using Laravel League s3

S3 存儲桶中有一個名為uploads//的目錄,我想將我的文件上傳到那里,因為它已經在現有的 Web 應用程序中使用,當我嘗試使用 Laravel League 上傳到uploads//時,它忽略了兩個斜杠。 所以我添加了///並且它也被忽略並且文件上傳到一個帶有uploads的新文件夾。

例子:

我希望文件上傳為

uploads//attachments/filename.jpg

目前一個斜線被忽略並上傳為

uploads/attachments/filename.jpg

這是相關的代碼片段:

// assume path as '/attachments/filename.jpg'
if($isPathDifferent==0){
    $path =  'uploads//'. $path;
}
$upload = Storage::disk('s3')->store($path, file_get_contents($file));
Storage::disk('s3')->setVisibility($path, 'public');

請注意,我無法更改名稱uploads//因為它有很多資源和用途。

請應用以下解決方案,它應該可以解決您的問題

$path = Storage::disk('s3')->put('uploads/', $file);

暫無
暫無

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

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