I need to upload a image from iOS device to web service. While uploading image i used;
NSData* pictureData = UIImagePNGRepresentation(originalImage);
Actually it works fine. However the images i uploaded does not show up in IE. I tried uploading both JPG and PNG i can see the images in all other browsers but it does not work in IE. So i thought that it can be about converting it to NSData.
Is there any other way to convert UIImage to NSData?
Or any other idea that might be causing the problem?
Here is the way i upload the image;
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary];
[request setValue:contentType forHTTPHeaderField: @"Content-Type"];
NSMutableData *body = [NSMutableData data];
NSData* pictureData = UIImagePNGRepresentation(originalImage);
if (pictureData) {
[body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"image.JPG\"\r\n", FileParamConstant] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: image/jpeg\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:pictureData];
[body appendData:[[NSString stringWithFormat:@"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
}
[body appendData:[[NSString stringWithFormat:@"--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];