iOS 图片上传

//对图片进行转码

 NSString *imageData = [UIImageJPEGRepresentation(image, compression) base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];

    NSMutableDictionary *parmDic = [NSMutableDictionary dictionary];

    [parmDic setObject:imageData forKey:@"data"];

    [LMHttpTool postWithUrl:@"换成上传图片的地址" params:parmDic image:image compression:compression successBlock:^(AFHTTPRequestOperation *operation, id responseObject) {

     上传成功

       } errorBlock:^(AFHTTPRequestOperation *operation, id responseObject) {

        LMLog(@"图片error : %@", responseObject[@"message"]);

    } failBlock:^(AFHTTPRequestOperation *operation, NSError *error) {

        LMLog(@"图片file : %@", error);

    }];

你可能感兴趣的:(图片上传)