1

Here what I have so far, and for some reason,

I couldn't get it to save to database.

I've check everything.

Can someone tell me what did I do wrong ?

But for some reason, the file is save to my local system.

$user                = new User;
        $user->firstname = Input::get('firstname');
        $user->lastname  = Input::get('lastname');
        $user->username  = Input::get('username');
        $user->email     = Input::get('email');



$logo_path = Input::file('logo_path');

        if (Input::hasFile('logo_path'))
        {

            $file            = Input::file('logo_path');
            $destinationPath = base_path().'/app/files/logo_path/';
            $filename        = $file->getClientOriginalName();
            $uploadSuccess   = $file->move($destinationPath, $filename);
            $user->logo_path = $filename;
        }

            return Redirect::to('/users/')
            ->with('success',' Your Account has been created');

        }
1
  • 1
    Is there some error message? Can you detail the desired behavior and add more details to your question? Commented Nov 21, 2014 at 16:47

2 Answers 2

1

I notice you forget one most important thing.

Try this $user->save(); before return Redirect. Let me know.

Sign up to request clarification or add additional context in comments.

Comments

1

You did not execute save() method your code should be

$user = new User;
$user->firstname = Input::get('firstname');
$user->lastname = Input::get('lastname');
$user->username = Input::get('username');
$user->email = Input::get('email');

if (Input::hasFile('logo_path'))
        {
            $allowedext = array("png","jpg","jpeg","gif");
            $photo = Input::file('logo_path');
            $destinationPath = public_path().'/uploads';
            $filename = str_random(12);
            $extension = $photo->getClientOriginalExtension();
            if(in_array($extension, $allowedext ))
            {
                $upload_success = Input::file('logo_path')->move($destinationPath, $filename.'.'.$extension);
            }
}

$user->photo = $filename ; $user->save(); please mind the variable names

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.