2 peterchen149 peterchen149 于 2015.06.15 17:27 提问

使用nsurlsesseionuploadtask上传图片发生错误
ios

直接上代码:

     NSURL *url = [NSURL URLWithString:urlStr];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    NSURLSession *session = [NSURLSession sharedSession];
    NSURLSessionUploadTask *uploadTask   = [session uploadTaskWithRequest:request fromData:imgData completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSString *string = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
        NSLog(@"data str:%@",string);
        NSLog(@"success:%@",response);
        NSLog(@"error:%@",error);
    }];
    [uploadTask resume];

imgdata 和urlstr都是传进来的参数,
运行之后就报错:
error:Error Domain=NSURLErrorDomain Code=-1017 "cannot parse response" UserInfo=0x7fec6db0f070 {NSUnderlyingError=0x7fec6db0a280 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1017.)", NSErrorFailingURLStringKey=http://172.23.128.57:89/jf/platform/upload/appUpload, NSErrorFailingURLKey=http://172.23.128.57:89/jf/platform/upload/appUpload, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-1, NSLocalizedDescription=cannot parse response}
请问怎么解决

Csdn user default icon
上传中...
上传图片
插入图片