实现多文件上传在iOS开发中

时间:2021-05-23 20:43:22

该功能实现了实现多文件上传在iOS开发中,喜欢的朋友可以研究一下吧。

NSURL* url = [NSURL URLWithString:@"xxx"];
ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
request.uploadProgressDelegate = viewPost.progressView;
request.showAccurateProgress = YES;
request.shouldContinueWhenAppEntersBackground = YES; if ([imageArray count] > 0)
{
[request setPostFormat:ASIMultipartFormDataPostFormat];
for (NSData* data in imageArray) {
NSInteger idx = [imageArray indexOfObject:data];
[request addData:data withFileName:[NSString stringWithFormat:@"image%d.png",idx] andContentType:@"image/png" forKey:@"photos[]"];
}
}

相关文章