Skip to content
Om Puter

Om Puter

Berbagi Tutorial Coding dan Pemrograman Komputer

Menu
  • Channel YouTube ThirteeNov
  • Channel YouTube Om Puter
Menu

Cara menyimpan gambar dengan format base64 ke dalam direktori di server kita

Posted on 4 Oktober 20214 Oktober 2021 by OmPuter

Di bawah ini adalah snippet kode PHP untuk nge-post data berupa gambar dengan format base64 dan menyimpannya dalam sebuah direktori di server kita:

//Upload and store base64 image
$myimage = "gambarku";
define('UPLOAD_DIR', 'uploads/');
$image_parts = explode(";base64,", $_POST['imagedata']);
$image_type_aux = explode("image/", $image_parts[0]);
$image_type = $image_type_aux[1];
$image_base64 = base64_decode($image_parts[1]);
$file = UPLOAD_DIR . $myimage . '.jpg';
file_put_contents($file, $image_base64);
Post Views: 1,643

Kategori

  • 3D Max
  • Adobe Animate
  • Android
  • c#
  • Cordova
  • HTML5, CSS & JavaScript
  • iOS
  • Lain-lain
  • Photoshop
  • PHP
  • Python
  • Roblox
  • Tak Berkategori
  • Unity
  • WordPress
ciihuy2020
© 2026 Om Puter | Powered by Superbs Personal Blog theme