使用MKNetworkKit上传多个图像

时间:2012-06-22 14:43:28

标签: iphone ios mknetworkkit

我正在使用MKNetworkKit来获取服务器请求。如何使用这种JSON格式上传多个图像文件?

"pictures": [
    {
        "name": "pic1",
        "qty": 1,
        "size": 312
    },
    {
        "name": "pic2",
        "qty": 2,
        "size": 123
    }
]

我见过的大多数示例代码都是:

MKNetworkOperation *op = [self.flUploadEngine postDataToServer:postParams path:@"/post.php"]
[op addFile:imageData1 forKey:@"firstImage"]; 
[op addFile:imageData2 forKey:@"secondImage"];

由于

1 个答案:

答案 0 :(得分:0)

    NSData *dataWithData1=UIImageJPEGRepresentation([ary_image_upload objectAtIndex:i],90);

    [self.flOperation addData:dataWithData1 forKey:@"userfl" mimeType:@"image/jpeg"fileName:imageName];

把代码试试这个