![](/img/trans.png)
[英]Check if file exists with Laravel 5.5 Storage? Storage for Avatar
[英]Storage facade get method in returns File not found at path while file exists - Laravel 5.5
我已經在文件系統配置中添加了本地磁盤
'customDisk' =>
[
'driver' => 'local',
'root' => 'D:\RandomFolder',
],
在我的數據庫Seeder中,有以下行
$file = Storage::disk('customDisk')->get($filename);
我收到以下錯誤-在路徑:路徑/名稱中找不到文件。
問題是該文件確實存在,我不明白為什么這會引發錯誤。
我知道我可以使用File :: facade,但是我對此有其他擔憂,因此我寧願不使用它。
從您先前的評論中,我現在可以看到問題了。 您說您的文件返回文件的內容,其中可能包含大小,mimeType,路徑等。 因此,您必須只讀取該變量的路徑,或者在將其用於存儲之前對其進行解碼:
Storage::disk('customDisk')->get($filename->path)
要么:
$file = json_decode($filename);
$path = $file->path;
Storage::disk('customDisk')->get($path);
沒有測試它,但這應該給您想要的輸出。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.