Note that there are some explanatory texts on larger screens.

plurals
  1. POUpload image to Web Service
    primarykey
    data
    text
    <p>Ok, so I have this web service that uses a user's email &amp; password and has to convert an image to a base64 string and then upload through a asmx service. Any clues on how to accomplish this? I have to do this through an iOS/xcode app. I was trying this code</p> <pre><code>- (IBAction)uploadImage:(NSData *)imageData filename:(NSString *)filename{ NSString *fullURL = @"www.example.com/asmx/imageupload.asmx"; NSURL *urlString= [NSURL URLWithString:fullURL]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:urlString]; [request setHTTPMethod:@"POST"]; NSString *boundary = @"---------------------------14737809831466499882746641449"; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary]; [request addValue:contentType forHTTPHeaderField: @"Content-Type"]; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@\"\r\n",filename]] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[@"Content-Type: application/octet-stream\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:imageData]]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:body]; NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; [self uploadImage:UIImageJPEGRepresentation(imageView.image, 1.0) filename:image]; }; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload