Level 102
Why not let laravel handle it for you?
if ($request->hasFile('image')) {
$data['photo'] = $request->file('image')->store('uploads/admin_images', 'public');
}
Be aware that it goes in /storage/app/public
I am not able to save images , Database is showing image name however under destination folder it's showing .tmp I checked other posts for same issue and try to fix it but still getting same. Can anyone please pinpoint it? Thanks
In Controller - public function update_profile(Request $request){
$id = Auth::user()->id;
$data = User::find($id);
$data->name = $request ->name;
$data->email = $request ->email;
$data->phone = $request ->phone;
$data->address = $request ->address;
if ($request->hasFile('image')) {
$file =$request->file('image');
$filename = date('YmdHi').$file->getClientOriginalName();
$file->move(public_path('uploads/admin_images'));
$data['photo']= $filename;
}
$data->save();
return redirect()->back();
HTML Form
Because you're moving a .tmp file and not specifying the new name (second argument):
$file->move(public_path('uploads/admin_images/'), $filename);
Please or to participate in this conversation.