Last active
May 14, 2019 19:10
-
-
Save sagar290/c1790b520c1df716de90ae1546da408f to your computer and use it in GitHub Desktop.
Get image as base 64 format and insert DB
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
<?php | |
class ImageController { | |
public function addEmployee(Request $request) | |
{ | |
$pp = $request->pp; | |
$image_name = ''; | |
if ($pp) { | |
list($type, $image) = explode(';', $pp); | |
list(, $image) = explode(',', $image); | |
$image = base64_decode($image); | |
$image_name= "https://lms10.s3.ap-southeast-1.amazonaws.com/main/ublbb/pp/".time().".png"; | |
$store = Storage::disk('s3')->put('main/ublbb/pp/'.$image_name, $image, 'public'); //You can use local file by changing the disk('local) | |
} | |
$user = new User; // Initialize Model in $user variable | |
$user->pp = $image_name; | |
if ($user->save()) { | |
return 'success'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment