File: /var/www/html/www.winghung.com/demo_v6/example3/upload.php
<?php
//upload.php
/*$folderPath = 'upload/';
$image_parts = explode(";base64,", $_POST['image']);
$image_type_aux = explode("image/", $image_parts[0]);
$image_type = $image_type_aux[1];
$image_base64 = base64_decode($image_parts[1]);
$file = $folderPath . uniqid() . '.png';
file_put_contents($file, $image_base64);
echo $file;*/
if(isset($_POST["image"]))
{
$data = $_POST["image"];
$image_array_1 = explode(";", $data);
$image_array_2 = explode(",", $image_array_1[1]);
$data = base64_decode($image_array_2[1]);
$imageName = 'upload/' . time() . '.png';
file_put_contents($imageName, $data);
echo $imageName;
}
?>