Currently I'm developing an app that's able to snap photos and upload to a server and return true and photo name using appery.io. Now I'm able to snap the photo and get the image in imageDataBase64 format, but I don't know how to upload it to my database. I have followed the example available online but I still can't upload the image, I get:
Request-URI Too Large The requested URLs length exceeds the capacity limit for this server.
Below are the images that I created in appery.io and the API that I use to upload my photo.
$data = $_POST['data'];
$servername = "localhost";
$username = "kipkad_mage154";
$password = "momoko123";
$dbname = "kipkad_demo_kipcard";
$conn = new mysqli($servername, $username, $password, $dbname);
$file_path = realpath("../media/rewardreceipt/");
$base64img = str_replace('data:image/jpeg;base64,', '', $base64img);
$data = base64_decode($base64img);
$file = $file_path . uniqid() . '.jpeg';
$success = file_put_contents($file, $data);
if (move_uploaded_file($success, $file_path) {
$arr = array('result' =>$file);
echo json_encode($arr);
} else{
$arr = array('result' =>'false');
echo json_encode($arr);
}