shan_biswas's avatar

Get uploaded file name after hashing and save it to database along with other values

I have a user registration form with a file upload option. All the data are getting saved in database correctly except the file name. I am getting the temporary file name, not the actual file name generated by laravel.

I am getting file name something like "C:\xampp\tmp\php9324.tmp" and it is being saved in database.

With the 3rd line of my below code the file is getting uploaded successfully in "temp-uploads/" and a hashed file name is generated automatically. I want to retrieve that hashed file name and save to database.

My Code to save data in database

public function store(ValidateRegistration $request)
{  
    $path = $request->file('profile_pic')->store('temp-uploads');
    $request['profile_pic'] = $path;
        
    // Save the data
    User::create(request(['fname','lname','phone','email','password', 'profile_pic']));
    
    // redirect to home page
    return redirect('/registration-success');
}
0 likes
0 replies

Please or to participate in this conversation.