I am having an app in which I am uploading user's data on webserver.

I am using the below code to pass the data to webserver with the code below.

```
-(IBAction)btnRegister:(id)sender
{
    jsonSP = [SBJSON new];
    jsonSP.humanReadable = YES;

     NSString *service = @"/register.php";
    NSData *imageData = UIImagePNGRepresentation([UIImage imageNamed:@"register_btn.png"]);
    [Base64 initialize];
    NSString *imageString = [Base64 encode:imageData];
    NSLog(@"%@",imageString);

    NSString *requestString = [NSString stringWithFormat:@"{\"?username\"=\"%@\"&\"user_password\"=\"%@\"&\"first_name\"=\"%@\"&\"email\"=\"%@\"&\"profile_photo_link\"=\"%@\"\"}",@"Test",@"Test",@"Test",@"Test@mmm.com",imageString];
    NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];

    NSString *fileLoc = [[NSBundle mainBundle] pathForResource:@"URLName" ofType:@"plist"];
    NSDictionary *fileContents = [[NSDictionary alloc] initWithContentsOfFile:fileLoc];
    NSString *urlLoc = [fileContents objectForKey:@"URL"];
     urlLoc = [urlLoc stringByAppendingString:service];
    NSLog(@"URL : %@",urlLoc);
   // urlLoc = [urlLoc stringByAppendingString:@"?username=abcd&password=abcd"];
    urlLoc = [urlLoc stringByAppendingString:requestString];
    urlLoc = [urlLoc stringByReplacingOccurrencesOfString:@"{" withString:@""];
    urlLoc = [urlLoc stringByReplacingOccurrencesOfString:@"}" withString:@""];
    urlLoc = [urlLoc stringByReplacingOccurrencesOfString:@"\"" withString:@""];
    NSLog(@"URL : %@",urlLoc);
    // [fileContents release]; //o_r
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL: [NSURL URLWithString: urlLoc]];
    NSString *postLength = [NSString stringWithFormat:@"%d", [requestData length]];
    [request setHTTPMethod: @"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody: requestData];

    //    self.connection = [NSURLConnection connectionWithRequest:request delegate:self];

    NSError *respError = nil;
    NSData *returnData = [NSURLConnection sendSynchronousRequest: request returningResponse: nil error: &respError ];
    NSLog(@"response is %@",returnData);

    // [request release];
    if (respError)
    {
        //[customSpinner hide:YES];

        UIAlertView *alt=[[UIAlertView alloc]initWithTitle:@"Internet connection is not Available!" message:@"Check your network connectivity" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
        [alt show];
        //[alt release];

    }
    else
    {
        NSString *responseString = [[NSString alloc] initWithData:returnData encoding: NSUTF8StringEncoding];
        NSLog(@"response string %@",responseString);
    }
}

```

I am successfully able to send the data to webserver without the image.

But if upload the image with the code shown above by encoding Base64 then the data is not uploaded on webserver. **It gives me an error in NSLog saying request query string too long.**

I have already imported Base64.h and .m files. 

I want to pass the data with image also.

How can I do that?

I know there are lots of links but I want to pass it this way so please tell me what is wrong I am doing here?

Please help me.

Thanks in advance.