I have my app that generates a base64 string as the b64data variable that I’m sending to the server and then decoding in PHP server-side. The base64 image it generates is linked in below since it’s so long and the code below is from my app function that generates the base64. Having trouble understanding where the error is in the base64 image syntax. Any help is appreciated!
Javascript should not be restricted. Look at the settings of the server to the maximum size of the POST request. You can also try using multipart/form-data instead of application/x-www-form-urlencoded.
You also need to check the processing of incoming data by the server. Perhaps some characters are escaped. I do not see in your code base64 sign “+”. Most likely it is replaced with something.
I did as well. If I change the code in my PHP file right on the server to my full base64 string then it works great server-side. The issue is that for some reason when the app sends the base64 to the server it gets cut off. The base64 string is huge I know. On server-side it isn’t an issue because my PHP creates a JPG out of it anyway. I just need to get that huge string to POST!
I think that photo resolution is not a problem. Please share the contents of base64 from console.log (base64) from the application and the result of base64 on the server. It must be the same image. I want to compare the content of the base64.
The console.log (b64data) output is also required from the application for the same image. I want to compare the contents of base64 in the application and on the server for the same image.
function capturePhoto() {
Camera.capturePhoto(5,5)
.then(function (photo) {
photo.save()
.then(function(filePath) {
console.log("Photo saved to: " + filePath);
var arrayBuff = FileSystem.readBufferFromFileSync(filePath);
b64data = Base64.encodeBuffer(arrayBuff); // send this to the backend
//###############
console.log(b64data); //Send me the result
//###############
photo.release();
})
.catch(function(error) {
console.log("Failed to save photo: " + error);
photo.release();
});
})
.catch(function (error) {
console.log("Failed to capture photo: " + error);
});
}
Well now I’m working on getCameraInfo and I believe if I could set the resolution to maybe 600x600 I can make this work. Below is the code I am working on.
function getCameraInfo() {
Camera.getCameraInfo()
.then(function(info) {
console.log("photoResolution: " + info[Camera.INFO_PHOTO_RESOLUTIONS]);
console.log("captureMode: " + info[Camera.INFO_CAPTURE_MODE]);
console.log("flashMode: " + info[Camera.INFO_FLASH_MODE]);
console.log("cameraFacing: " + info[Camera.INFO_CAMERA_FACING]);
console.log("supportedFlashModes: " + info[Camera.INFO_SUPPORTED_FLASH_MODES].join());
captureMode.value = info[Camera.INFO_CAPTURE_MODE];
flashMode.value = info[Camera.INFO_FLASH_MODE];
if (Camera.INFO_PHOTO_RESOLUTIONS in info) {
var availableResolutions = info[Camera.INFO_PHOTO_RESOLUTIONS];
availableResolutions.forEach(function(e) {
console.log(600 + "x" + 600);
});
photoResolution = availableResolutions[Math.floor(availableResolutions.length * 0.4)];
var options = {};
options[Camera.OPTION_PHOTO_RESOLUTION] = photoResolution;
Camera.setPhotoOptions(options)
.then(function() {
console.log("New photo options set: " + JSON.stringify(options));
})
.catch(function(error) {
console.log("Failed to set photo options: " + error);
});
}
})
.catch(function(err) {
console.log("Failed to get camera info: " + err);
});
}
getCameraInfo();
It is necessary to search for a problem in difference of the sent data base64 (through console.log (b64data)) and received (PHP $ _POST). Share the result of console.log (b64data) and base64 on the server for the same image. Until you share this data - I can not help.