Skip to content

Instantly share code, notes, and snippets.

@Merazsohel
Created January 12, 2018 18:36
Show Gist options
  • Save Merazsohel/7e564b11d96f6d78058cca529dfeb4ec to your computer and use it in GitHub Desktop.
Save Merazsohel/7e564b11d96f6d78058cca529dfeb4ec to your computer and use it in GitHub Desktop.
Laravel-image
$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