I am taking a photo from my Android application using this code:
if (requestCode == CAMERA_REQUEST && resultCode == RESULT_OK){
photo = (Bitmap) data.getExtras().get("data");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
photo.compress(Bitmap.CompressFormat.JPEG, 40, baos);
byte[] photoByte = baos.toByteArray();
encodedImage = Base64.encodeToString(photoByte,Base64.DEFAULT);
}
I send this line encodedImageto my PHP server via POST and get it $encodedImage. I have a database where I have a myImagetype field MEDIUMBLOB. I tried to save encodedImageto myImage, but it is saved as a damaged image. I tried to save how base64_decode($encodedImage), but somehow it didn't work.
I want to do three things:
, .
, .
PHP- :
$baseImage = $_POST['baseImage'];
$blobImage = base64_decode($baseImage);
$query = "INSERT INTO `complaints`(`myImage`,...) VALUES ('$blobImage',...)"
$result = mysqli_query($conn,$query);