<?php

if (isset($_POST["imageForDataURI"]) || !empty($_POST["imageForDataURI"])) {
$image = $_POST["imageForDataURI"];
$type = pathinfo($image, PATHINFO_EXTENSION);
$data = file_get_contents($image);
$dataUri = 'data:image/' . $type . ';base64,' . base64_encode($data);

echo $dataUri;
}

?>