码迷,mamicode.com
首页 > 移动开发 > 详细

IOS上传多张图片(ASIHTTPRequest)

时间:2016-08-24 13:05:24      阅读:390      评论:0      收藏:0      [点我收藏+]

标签:

    /*

     上传图片

     */

    //#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];

IOS上传多张图片(ASIHTTPRequest)

标签:

原文地址:http://www.cnblogs.com/qiulilin/p/5802161.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!