Use bellow code for store image in public Directory with resize image and image path store in database field.
$input = Input::all();
$file = array_get($input, 'image');
$destinationPath = public_path('images');
$fileName = $request->image->getClientOriginalName();
$imageResize = Image::make($file->getRealPath())
->resize(50,50,function($c){$c->aspectRatio(); $c->upsize();})->save($destinationPath.'/'.$fileName);
$filepath = $destinationPath.'/'.$path;
$insert = array('username' => Input::get('username'),
'image' => $filepath,
);
DB::table('users')->insert($insert);
Hope, this work for you.
Its not even entering into store function after user registers.I have used the existing RegisterController.php which comes in make:auth of laravel [app\Http\Controllers\Auth\RegisterController.php] and defined store function there. when user register in the form[register.blade.php], the action called is-> action="{{ route('register') }}".after the user clicks submit ,it enters into RegisterController to validate user information. My questions is whether we can write functions inside laravel auth\RegisterController.php. In Router.php :
// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');
if I add my store function, it doesn't execute.
So, I tried writing my store function inside \vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers.php=>which uses trait RegistersUsers.
The output in http://localhost:8000/register/store ""Sorry, the page you are looking for could not be found.NotFoundHttpException in RouteCollection.php line 179:"
How to proceed further.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community