Postingan lainnya
Kelas Premium!
Belajar Javascript untuk website
Gunakan kupon "mulaijs" untuk diskon 75 ribu!
upload image dengan canvas
tanya gan:
ane punya coding
Html:
<button id="download_image" class="button small-btn primary-btn upgradeBtn">Download</button>
javascript
<script type="text/javascript">
$("#download_image").click(function(e) {
e.preventDefault();
image = canvas.toDataURL();
$.ajax({
type: 'POST',
url: "/save-leader-board",
contentType: "application/json;",
dataType: "json",
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data: {
imgBase64: image,
},
success: function(data) {
alert(data.d);
},
error: function(data){
alert("fail");
}
})
});
</script>
php.
<?php
$image = $request->imgBase64; // your base64 encoded
$image = str_replace('data:image/png;base64,', '', $image);
$image = str_replace(' ', '+', $image);
$imageName = str_random(10).'.'.'png';
\File::put(storage_path(). '/images/' . $imageName, base64_decode($image));
?>
created image di storage berhasil tapi tampilan nya seperti file image corrupt
mohon pencerahnnya gan
0
2 Jawaban:
<div>Silahkan coba cek thread ini <a href="https://sekolahkoding.com/forum/upload-foto-webcam-ke-database-1642830658">https://sekolahkoding.com/forum/upload-foto-webcam-ke-database-1642830658</a> disitu udah ada contohnya, semoga terbantu.</div>
0
<div>done gan makasih delete code <br><br><br></div><pre>contentType: "application/json;"</pre>
0