i'm newbie in laravel
I'm just succesfully upload an image and store name in database. linkd 'public' folder to 'storage/App/public' also but can't show it on the page. image is also on that folder with protected random name. I can't load image with that url also 'http://localhost:8000/storage/flower.jpg'. what should i do now ????
web.php
Auth::routes();
Route::post('/update/{id}','HomeController@update')->name('update');
Route::get('/home', 'HomeController@index')->name('home');
HomeContoller.php
public function update(Request $request,$id){
$student = user::find($id);
if ($file = $request->file('profile_image')) {
$file = $request->file('profile_image');
$request->file('profile_image')->store('public/');
$img_nm = $file->getClientOriginalName();
$request->file('profile_image')->getClientOriginalName();
$student->image = $img_nm;
}
$student->username = $request ->username;
$student->first_name = $request ->first_name;
$student->last_name = $request ->last_name;
$student->gender = $request ->gender;
$student->email = $request ->email;
$student -> save();
return redirect()->route('home');
}
home.blade.php
<td>
<img src="{{ asset('storage/'.$student-> image) }}"/>
</td>
fileSystems.php
'default' => env('FILESYSTEM_DRIVER', 'local'),
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
Options Indexes FollowSymLinks
for your project<Directory>
in your apache site config. – Vinay