0

I used mysql to store the picture and it is stored by longblob. Now I need use json the transfer the data of longblob. The json_endcode($data) returns null. How to do it?

Sergio
  • 6,900
  • 5
  • 31
  • 55
MarkWill
  • 13
  • 3

2 Answers2

1

You could try to serialize image data to base64, but it seems to be a bad idea, since images can be really big. You better store it on ftp server and write just links to images to database

Sergio
  • 6,900
  • 5
  • 31
  • 55
  • I need to store the message of String ,pictures and voice, so I used the longblob to store all kinds of data in mysql. Do you have some better idea in this situation. – MarkWill Jul 22 '13 at 14:01
  • 1
    Just imagine your database size after couple month of highload. rdbms aint a silver bullet, you don't want to store everything there – Sergio Jul 22 '13 at 14:04
1

Please check this question - Binary Data in JSON String. Something better than Base64

binary data can be encoded into base64 otherwise JSON does not support it

The JSON format natively doesn't support binary data. The binary data has to be escaped so that it can be placed into a string element (i.e. zero or more Unicode chars in double quotes using backslash escapes) in JSON.

Community
  • 1
  • 1
Vladimir Hraban
  • 3,543
  • 4
  • 26
  • 46