0

Good Afternoon Stack Overflow

I have an issue with posting an image from an iOS device to a php-webserver using base64 encoding.

I have converted a UIImage to a string in xcode using;

NSString *imageString = [UIImagePNGRepresentation(attachmentImage) base64EncodedStringWithOptions:0];

Fired it over to the server using http post, this is fine as I have echo-ed exactly the same string back and have seen this working.

And server-side I am decoding using;

$decoded = base64_decode($base64string);
file_put_contents($targetFile, $decoded);

The smug android guy sitting next to me has successfully put this into his version of the app and it works fine using the php script containing the above code.

Although my knowledge of base64 is limited, I have checked that the 2 non alpha numeric characters used for encoding are standard ('+','/') and as I mentioned earlier I have checked the communication between the app/server - this is fine.

Right now I am thinking there maybe a problem with converting the UIImage to a png but everything I have searched points me at the commands Im already using.

I have been on this now for almost a day and i am quick running out of hair to pull out - any help would be appreciated.

Thanks in advance

0 Answers0