0
点赞
收藏
分享

微信扫一扫

ios实现多文件上传

善解人意的娇娇 2023-04-30 阅读 83


如果使用ASIHTTPRequest同时向服务器发送多张图片

NSURL* url = [NSURL URLWithString:@"xxx"];
   ASIFormDataRequest* request = [ASIFormDataRequest requestWithURL:url];
  uploadProgressDelegate = viewPost.progressView;
  showAccurateProgress = YES;
  shouldContinueWhenAppEntersBackground = YES;
   
  if ([imageArray count] > 0)
{
       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[]"];

举报

相关推荐

0 条评论