vinaysoni_1910's avatar

Files are getting saved as .tmp

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

Upload Profile Image
0 likes
5 replies
Sinnbeck's avatar

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

tykus's avatar
tykus
Best Answer
Level 104

Because you're moving a .tmp file and not specifying the new name (second argument):

$file->move(public_path('uploads/admin_images/'), $filename);
1 like

Please or to participate in this conversation.