使用NSURLSessionUploadTask上传视频时缺少边界

时间:2015-07-16 13:31:42

标签: php ios nsurlconnection nsurlsession nsurlsessionuploadtask

使用NSURLSessionUploadTask上传视频时服务器上出现错误,服务器错误说明:

  

PHP警告:第0行的未知中的multipart / form-data POST数据中缺少边界

这是我的代码:

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];

    NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];

    NSString *finalURLFormat = [NSString stringWithFormat:@"%@%@", kAPIUrl, url];
    NSMutableURLRequest *request = [self setHeadersForURL:finalURLFormat Method:@"POST"];

    [request setHTTPMethod:@"POST"];



    NSURLSessionUploadTask *postDataTask = [session uploadTaskWithRequest:request fromFile:data completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSError *jsonError;

        NSDictionary *jsonResponse =
        [NSJSONSerialization JSONObjectWithData:data
                                        options:NSJSONReadingAllowFragments
                                          error:&jsonError];

        if (!jsonError) {
            NSHTTPURLResponse *httpResp = (NSHTTPURLResponse*) response;

            if (httpResp.statusCode < 400) {


            }
            else {


            }
        }

    }];

    [postDataTask resume];

0 个答案:

没有答案