[英]Get full path to file with Laravel Storage
我正在使用 Laravel 5.6 Storage API 將我的文件public/storage/images
在public/storage/images
。 這工作正常。 當我想檢索這些文件之一的完整 URL 時,我使用
$path = Storage::disk('public')->url('images/' . $url);
這返回
但是由於我的服務器設置為忽略public
,因此該地址不會返回圖像。 相反,這個地址:
返回圖像。 有沒有辦法使用 Laravel 的 API 生成這個地址,而不是進行丑陋的查找和替換?
嘗試此步驟以ignore public
路徑中的ignore public
1)Rename `service.php` to `index.php` in your root drive
2)copy `.htaccess` file from public folder and paste into root drive
現在在 url 中不公開地運行您的代碼
在根目錄中創建一個 .htaccess 文件並添加
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ public/index.php/$1 [L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.