I have to call one webservice php side and send image byte array but my problem is this web service call when i am upload image so must need to send direct byte array in json post.
Asked
Active
Viewed 8,131 times
1
-
is this your webservice? – dandavis Jul 23 '15 at 08:42
-
yes but i have not eligible for change or add code in webservice. – Nikunj Chotaliya Jul 23 '15 at 08:45
-
JSON doesn't support byte arrays. it's not easy to ship binary strings in JSON either, so your best best is send()ing a Blob or base64 string and decoding it in php. – dandavis Jul 23 '15 at 08:46
-
Not sure if [http://stackoverflow.com/questions/10687270/convert-image-to-byte-with-php](http://stackoverflow.com/questions/10687270/convert-image-to-byte-with-php) is of any help! – lshettyl Jul 23 '15 at 08:47
-
as i have say i am not eligible to change or add coded because this webservice is already use for iphone and iphone developer send json with image byte array so i have to also use this webservice for my web. – Nikunj Chotaliya Jul 23 '15 at 08:48
-
1@dandavis, JSON supports byte array, I've already implemented so – Tirthak Shah Jul 23 '15 at 08:49
-
@Ishettyl i have already that code but i will not change server side. – Nikunj Chotaliya Jul 23 '15 at 08:50
-
@TirthakShah: not according to http://www.json.org/ it doesn't, and that what all the utilities are based upon. if you can't/won't change your server code, then you will have to give up on this feature. – dandavis Jul 23 '15 at 08:51
-
@dandavis as Nikunj mentioned this service is already in use by Iphone Devices, so it is working with Json. And as I mentioned I also have used it. It may not be better to use byte array like this, but It supports, you can even check SO for details. – Tirthak Shah Jul 23 '15 at 09:08
-
@TirthakShah: do you have a link? i'm not 100% sure what you're referring to. – dandavis Jul 23 '15 at 09:18
-
@NikunjChotaliya Is it **multipart/form-data** service ? – jagad89 Jul 23 '15 at 09:20
-
@jagad89 this webservice is only accept data with post and in json format with one profile image key and it value is byte array – Nikunj Chotaliya Jul 23 '15 at 09:22
-
@NikunjChotaliya Can you post webservice sample request? Generally it takes base64 encoded string. – jagad89 Jul 23 '15 at 09:31
-
@NikunjChotaliya you can convert image to base64 encoded string using [this](http://jsfiddle.net/handtrix/YvQ5y/) and base64 encoded string to bytearray using [this](https://github.com/beatgammit/base64-js) – jagad89 Jul 23 '15 at 09:40