when i tried to change user profile avatar in localhost its working but when i tried on shared hosting its not working. please check my homecontroller code
public function upload(Request $request)
{
$validatedData = $request->validate([
'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
if($request->hasFile('image')){
$filename = $request->image->getClientOriginalName();
$unique_name = md5($filename. time());
$request->image->storeAs('images',$unique_name,'public');
Auth()->user()->update(['image'=>$unique_name]);
}
return Redirect('user/profile')->with("success","Profile image successfully changed!");
}
CodePudding user response:
Your images are going to storage
by default you can change it to public
by modifying config/filesystems.php
like this:
'disks' => [
'public' => [
'driver' => 'local',
'root' => public_path() . '/images', // change this to your desired path
'url' => env('APP_URL').'/public',
'visibility' => 'public',
]
]
And then access this storage by:
Storage::disk('public')->put('filename', $file_content);
CodePudding user response:
make sure you have link to your storage, so run this command
php artisan storage:link