簡體   English   中英

使用Apache使用Laravel后端查看圖像

[英]Viewing Image with Laravel backend with Apache

我的圖像存儲在我的storage / app / images文件夾中。

但是,如果沒有404標頭,我無法在localhost上訪問或查看任何這些圖像。

我正在使用Apache將以下htaccess用於我的Laravel REST API

RewriteEngine On
RewriteBase /backendLaravel/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]

我遵循了php artisan storage:link Laravel Docs提供的php artisan storage:link ,但沒有任何變化。

我希望能夠使用http公開訪問這些文件。 所以, http://endpoint/SDUpload/hello.jpeg

我如何實現這一目標

storage:link創建從public/storagestorage/app/public的符號鏈接。 嘗試將storage/app/images文件夾移動到storage/app/public/images或者使用以下命令創建從public/storage/imagesstorage/app/images的符號鏈接: ln -s storage/app/images public/storage/images

我沒試過這個,但我認為它會起作用。 在Laravel中有一個public_path()幫助器以及一個storage_path()幫助器。 如果您嘗試在html中在線顯示這些圖像,則可以嘗試使用存儲幫助程序。 這些助手中的每一個都用於訪問給定目錄,存儲或公共目錄。

例:

<img src="{{ storage_path('app/images/image.jpg')">

希望我能提供幫助。

暫無
暫無

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

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