I am using Unirest in my objective-c project. It is a very small but handy library.
https://github.com/Mashape/unirest-obj-c
However, I can't wrap my mind around how to POST array of files with Unirest.
If I were to build an HTML form, it will look like:
<input type="file" name="files[]" >
<input type="file" name="files[]" >
<input type="file" name="files[]" >
The file upload example from Unirest is:
NSDictionary* headers = @{@"accept": @"application/json"};
NSURL* file = nil;
NSDictionary* parameters = @{@"parameter": @"value", @"file": file};
UNIHTTPJsonResponse *response = [[UNIRest post:^(UNISimpleRequest *request) {
[request setUrl:@"http://httpbin.org/post"];
[request setHeaders:headers];
[request setParameters:parameters];
}] asJson];
Question: How do I adapt the example for multiple files?
- The receiving end of this POST request is a PHP page. I can change code there.