Level 15
Good Morning
I think your images should be at this path storage/app/public
If you run php artisan storage:link it should create this directory and add a sym link to your public directory. Please read more here - https://laravel.com/docs/5.4/filesystem#the-public-disk
Then from Laravel 5.3 you can do the following in your store method:
$model = Model::create($request->all());
if ($request->hasFile('image')) {
$request->file('image')->store('public/images');
// ensure every image has a different name
$file_name = $request->file('image')->hashName();
// save new image $file_name to database
$model->update(['image' => $file_name]);
}
// then in your view you reference the path like this:
<img src="{{ asset('public/images/' . $model->image) }}">
4 likes