IOS上传多张图片(ASIHTTPRequest)

    /*

     上传图片

     */

    //#define API_BASE_URL(_URL_) [NSURL URLWithString:[@"http://172.20.0.248:8080/BaiXin/mapi/" stringByAppendingString:_URL_]]

    

    ASIFormDataRequest *request=[ASIFormDataRequest requestWithURL:API_BASE_URL(@"uploadFile.do")];

    [request setPostValue:@"12345" forKey:@"RecordID"];

    [request setPostValue:@"19f4e51366bf4b42b404a4838a722fa0" forKey:@"UserID"];

    [request setTimeOutSeconds:10000];

    for (int i=0; i<[_photoView.photoMenuItems count]; i++) {

        UIImage *userHeadImage = [_photoView.photoMenuItems objectAtIndex:i];

        [request setData:UIImageJPEGRepresentation(userHeadImage,0.1)

            withFileName:[NSString stringWithFormat:@"%d.jpg",i]

          andContentType:@"image/jpeg/png"

                  forKey:[NSString stringWithFormat:@"file%d",i]];

    }

    [request setCompletionBlock:^{

        SBJsonParser *paser=[[SBJsonParser alloc]init];

        NSDictionary *rootDic=[paser objectWithString:request.responseString ];

        NSLog(@"上传成功%@",rootDic);

    }];

    [request setFailedBlock:^{

        NSLog(@"上传失败");

    }];

    [request startAsynchronous];

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。