lawkunchi
10 months ago

How do I request file input and save it in the databse?

Posted 10 months ago by lawkunchi
My Controller

public function postRegister(Request $request) 
   {
       $this->validate($request, [
           'first_name' => 'string|required|max:100',
           'last_name' => 'string|required|max:100',
            'file' => '';  //here
       ]);

       $user = new User([
           'first_name' => $request->input('first_name'),
           'last_name' => $request->input('last_name'),
           'file' => $request->input('file'),
       ]);
       $user->save();
}

My Migration

 public function up()
   {
       Schema::create('users', function (Blueprint $table) {
           $table->increments('id');
           $table->string('first_name');
           $table->string('last_name');
           $table->string('file')
       });
   }

Please sign in or create an account to participate in this conversation.