dimanche 8 mai 2016

Laravel 5.2 + upload file and save name in database

In laravel 5.2, I could upload file using below code but could not find a way to store uploaded filename in database.

    $destinationPath = "test/";
    $file = $request->file('profile_pic');
    if($file->isValid()){
        $file->move($destinationPath, $file->getClientOriginalName());
        $user = User::findOrFail(Auth::user()->id);
        $input = $request->all();
        $input['profile_pic']->pathname = $destinationPath.$file->getClientOriginalName();
        $user->update($request->all());
    }

Does anyone know how to store filename in db?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire