+ 2
Sending image through JSON
Is it possible to insert an image into database through JSON??
2 Réponses
+ 4
Yes but it would be inefficient.
The best you could do with JSON is encode all the raw image data using base 64. That would be making use of 6 bits per byte instead of 8. If you have a MongoDb, you could store the image as a document. If you have an SQL database, it is best to store raw image data using the BLOB type.
If you want to send the image over HTTP through JSON, base 64 is the best you can do. I generally wouldn't do this, though. I would send the image's data the same way as most file-upload forms work using an enctype of multipart/form-data because that is more efficient and closer matches how HTML forms usually work.
+ 5
Josh Greig is right ☝️