The storage folder is outside the public folder so you can't access the files via ndd.com/path/my_image.jpg.
You need something like this..
return response()->file(Storage::get('my_image.jpg'), ['Content-Type' => 'image/jpeg']);
Hello,
After research, I can not find good way to show the images that are upload in the "storage" folder.
How to get the right path, for example: "ndd.com/image-patch-on-storage" files to the "storage" folder and show this on view?
Thank you.
Finaly, I found simple solution, a route with a controller:
The route:
Route::group([
'prefix' => 'medias'
], function () {
Route::get('/{name}', 'MediaController@index');
});
The controller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Response;
use Storage;
class MediaController extends Controller
{
/**
* @param $name
* @return \Illuminate\Http\Response
*/
public function index($name)
{
if (!Storage::exists($name)) {
return Response::make('File no found.', 404);
}
$file = Storage::get($name);
$type = Storage::mimeType($name);
$response = Response::make($file, 200)->header("Content-Type", $type);
return $response;
}
}
Please or to participate in this conversation.