Upload multiple images using AFNetworking

前端 未结 5 973
别跟我提以往
别跟我提以往 2020-12-19 12:30

I used the PickerController and loaded a few images on to a NSMutableArray.

Now i need to upload all of these images at once. am using

5条回答
  •  失恋的感觉
    2020-12-19 13:28

    If you want to upload multiple images and you want to keep the parameter name same for all the images you do it as below :

    NSDictionary *parameters = @{@"user_key": @"*****"};
    NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:queryStringss parameters:parameters constructingBodyWithBlock:^(id formData) {
        NSError *error;
        [formData appendPartWithFileData:imageData name:@"photo_file[0]" fileName:@"Picture44.png" mimeType:@"image/png"];
        [formData appendPartWithFileData:imageData1 name:@"photo_file[1]" fileName:@"Picture45.png" mimeType:@"image/png"];
    } error:nil];
    

    In this way the files would be sent as array to the server.

提交回复
热议问题