Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay, I have managed to solve my problem. All parameters have to be set in form body, not as request values. It looks quite simple:</p> <pre><code> NSData *imageToUpload = UIImagePNGRepresentation([UIImage imageNamed:@"logo.png"]); if (imageToUpload) { NSString *urlString = @"https://post.imageshack.us"; AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:urlString]]; NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:@"/upload_api.php" parameters:nil constructingBodyWithBlock: ^(id &lt;AFMultipartFormData&gt;formData) { [formData appendPartWithFileData:imageToUpload name:@"fileupload" fileName:@"image" mimeType:@"image/png"]; [formData appendPartWithFormData:[@"XXXXXX" dataUsingEncoding:NSUTF8StringEncoding] name:@"key"]; [formData appendPartWithFormData:[@"json" dataUsingEncoding:NSUTF8StringEncoding] name:@"format"]; }]; AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { NSDictionary *jsons = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil]; NSLog(@"response: %@",jsons); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { if([operation.response statusCode] == 403) { NSLog(@"Upload Failed"); return; } NSLog(@"error: %@", [operation error]); }]; [httpClient enqueueHTTPRequestOperation:operation]; }} </code></pre> <p>Hope this will help someone!</p>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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