In Blade File use this code to capture image
In the Controller use this Code
<div class="form-group">
<label class="control-label col-md-3">Image<big class="text-danger">*</big></label>
<div class="col-md-4">
<div id="my_camera"></div>
</div>
<div class="col-md-4">
<div id="results">Your Image</div>
<input style="display:none" name="image" id="image" class="form-control" />
</div>
<input type=button value="Take Photo" onClick="take_snapshot()"></div>
// Webcam JS// <script> Webcam.set({ width: 195,
height: 100,
image_format: 'jpeg',
jpeg_quality: 90
});
Webcam.attach( '#my_camera' ); </script>
<script language="JavaScript">
function take_snapshot() { // take snapshot and get image data
Webcam.snap( function(data_uri) { // display results in page
document.getElementById('results').innerHTML = '<img src="'+data_uri+'"/>';
$("#image").attr('value',data_uri); } ); } </script> // Webcam JS//
In the Controller use this Code
$image = $request->image; $exploded=explode(',',$image);
$decoded=base64_decode($exploded[1]); if(Str::contains($exploded[0],'jpeg'))
{
$extention='jpg';
}
else{
$extention='png';
} $fileName=Str::random(15).'.'.$extention;
$path=public_path('images').'/'.$fileName;file_put_contents($path,$decoded); $form_data = array( 'image' => $fileName, );
1 Comments:
HTML Introduction
HTML Tags
HTML Elements
HTML Attributes
HTML Comments
HTML Headings
HTML Text Format
HTML Lists
Post a Comment