AFNetworking上传图片,

我这里用AFNetworking上传图片
报The data couldn’t be read because it isn’t in the correct format.有人帮忙看看是哪里出问题了么?下面是我写的代码。

    AFHTTPRequestOperationManager *m = [AFHTTPRequestOperationManager manager];
    m.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", @"application/json", nil];
    m.requestSerializer = [AFHTTPRequestSerializer serializer];
    [m.requestSerializer setValue:@"multipart/form-data" forHTTPHeaderField:@"Content-Type"];
    
    NS_APPDebugLog(@"请求链接:%@/%@", urlString, parametersDic);
    
    [m POST:@"http://59.48.96.118:7001/portal/SI_USR00025/upload.do" parameters:nil
                constructingBodyWithBlock:^(id<AFMultipartFormData>  _Nonnull formData) {
        for (int i = 0; i < imagePickerArray.count; i++)
        {
            UIImage *portraitImg = imagePickerArray[i];
            portraitImg = [UIImage scaleToSize:portraitImg];
            portraitImg = [portraitImg fixOrientation];
            NSData *imageData = [NSData compressImage:portraitImg];
            [formData appendPartWithFileData:imageData
                                        name:[NSString stringWithFormat:@"img.img%d", i+1]
                                    fileName:@"image.png"
                                    mimeType:@"image/png"];
        }
    } success:^(AFHTTPRequestOperation * _Nonnull operation, id  _Nonnull responseObject) {
        NSLog(@"成功");
    } failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
        NSLog(@"失败");
        dispatch_async(dispatch_get_main_queue(),^{failure(error);});
    }];
查看回复