2

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.

saveImageService

saveImgeAPI

$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);
}
Chris Harrison
  • 5,512
  • 3
  • 28
  • 36
chyman-91
  • 263
  • 3
  • 5
  • 12

1 Answers1

0

Check out this sample app: https://docs.appery.io/docs/samples-picture-upload-app -- it shows how to take a picture and upload it to the database using JavaScript API and also Cordova File API>

Max Katz
  • 1,582
  • 1
  • 9
  • 5