//在调用相机中获取图片
[manager POST:naurl parameters:requestParms constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
// 设置时间格式(给个时间便于区分)
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyyMMddHHmmss";
NSString *str = [formatter stringFromDate:[NSDate date]];
NSString *fileName = [NSString stringWithFormat:@"%@%d",str,i];
//要上传的文件(用个循环传多张)
/**
* data 将图片转换成data NSData *data=UIImagePNGRepresentation(image);
* name 服务器接受的name 两种格式1.数组,直接file可以穿多个进去 2.服务器端是键值 只能写file1 file2(看服务器的接受)
* filename 随意写
* mimeType 百度mime 看图片格式对应的mime
*/
[formData appendPartWithFileData:data name:[NSString stringWithFormat:@"file%d",i+1] fileName:fileName mimeType:@"image/png"];
}
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];