I am trying to save images in mysql database by encoding them in a base64 string and then passing them to a php script, which in turn stores this string in blob (I also tried the text). It happens that the string is sent to the PHP script as is, but when it is stored in the database, it is saved as a completely different string.
Here is how I do it:
Bitmap image = BitmapFactory.decodeFile("/sdcard/photo2.jpg"); ByteArrayOutputStream stream = new ByteArrayOutputStream(); image.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteImage = stream.toByteArray(); String s = Base64.encodeToString(byteImage, Base64.NO_WRAP | Base64.URL_SAFE);
And then the string 's' is passed to the php script (correctly, as I tested it), and the script in turn inserts it into the database.
This link http://diffchecker.com/kKD4w16C contains both the source encoded string (to the left of the screen) and the string that is stored in the database (to the right of the screen).
Any ideas why this is happening and how to prevent it?
Thanks in advance.
source share