Cannot see files in laravel on shared hosting Hi! I have a problem. My laravel doesn't see images on shared hosting.
I have public folder in ~/domains/DOMAIN/public_html/APP and rest of files in ~/domains/DOMAIN/FILES.
My files are uploading to ~/domains/DOMAIN/FILES/storage/app/public/uploads/avatars
but in app I can't see this. I display it like:
can you help me what to do?
You must save your avatar files in public accessible folder like
~/domains/DOMAIN/public_html/APP/uploads/avatars
Can you help me with this? How to do it?
Basically, the images which you wanted to show on your website should be stored after your domain name like yourdomain.com/images/avatars/11.jpg. So when you saving avatar save it into public folder because your domain name is pointed at your public_html/APP so you must save into that directory.
Or show me your file saving codes will help you.
That's the file
public function addAvatar(Request $request)
{
$this->validate($request, [
'file' => 'required',
]);
$user = $this->model->getUserById(Auth::user()->id);
$file = $request->file('file')->store('/public/uploads/avatars');
$filename = $request->file('file')->hashName();
$extension = pathinfo($file, PATHINFO_EXTENSION);
if($extension == 'png' OR $extension == 'jpg' OR $extension == 'jpeg'){
$file = UserData::avatar($request, $filename, $user->id);
return view('user.settings', compact('user'));
}
else
{
$file = unlink($request->file('file'));
return view('user.settings.files', compact('user'))->with('message', 'nope');
}
}
Change this line
$file = $request->file('file')->store(public_path() . '/uploads/avatars');
nothing changes. Cannot see image again
Please sign in or create an account to participate in this conversation.