Created
January 12, 2018 18:36
-
-
Save Merazsohel/7e564b11d96f6d78058cca529dfeb4ec to your computer and use it in GitHub Desktop.
Laravel-image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$image = $request->file('image'); | |
if ($image) { | |
$image_name = str_random(20); | |
$ext = strtolower($image->getClientOriginalExtension()); | |
$image_full_name = $image_name . '.' . $ext; | |
$upload_path = 'image/'; | |
$image_url = $upload_path . $image_full_name; | |
$success = $image->move($upload_path, $image_full_name); | |
if ($success) { | |
$data['image'] = $image_url; | |
DB::table('users')->insert($data); | |
Session::put('message', 'Registration Successfull!'); | |
return Redirect::to('add'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment