0

I am trying to upload a image onto server's database.

For that I have done

  1. Converted image to nsdata using UIImageJPEGReprenstation.
  2. Converted nsdata to nstring using base64lib.

Problem here is that nsstring that I have is NSASCII encoded.

So the default open ssl converters are not able to read the file and convert it into correct images on server side.

So what i need is

The nsstring that I have created from nsdata must not be encoded using nsascii or nsutf8 or something, as the image data is binary.

Or

On server side i must decode the data back to binary from nsascii or whatever way I have encoded on client side. But here the issue is I do not have any inbuilt api for ascii decoding.

Amol Ghotankar
  • 2,008
  • 5
  • 28
  • 42
  • 1
    This question doesn't make sense. You say you base64'd the binary data so you can put it into a string. The output of base64 is a subset of ASCII, so naturally the string would end up being encoded as ASCII. What exactly is the problem? You just need to un-base64 it on the server. – Icydog Oct 08 '11 at 00:11
  • Problem is when I decoded textual data on server it gets decoded properly but the binary data I guess is getting double encoded and is not getting decoded properly. – Amol Ghotankar Oct 08 '11 at 07:04

1 Answers1

0

Why do you need to convert the image data to string data? Couldn't you just do an HTTP POST with jpg data (MIME image/jpeg)? This post shows you how to do it.

Community
  • 1
  • 1
jbat100
  • 16,757
  • 4
  • 45
  • 70
  • On server side, i need to post it in the form of sql query string. So :( I wish i do directly post it to DB this way but can't so! – Amol Ghotankar Oct 07 '11 at 13:33
  • Is there any way in which I can convert the UIImage to simple file and then read the contents on the file in NSDATA and then encode it? – Amol Ghotankar Oct 08 '11 at 07:06