Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6957869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:04:03+00:00 2026-05-27T15:04:03+00:00

I am sending an image to the server by converting the NSData object into

  • 0

I am sending an image to the server by converting the NSData object into an NSString object using Base64 scheme by using….

 NSData *imgData=UIImagePNGRepresentation([objCP userImage]);
 NSString *encodedString=[Base64Coder encodeData:imgData];

I am observing a random behavior….sometimes I get “==” in the encoded string at the end of the string and image does not uploaded.There may be some other characters also in between the string.If I do not get these characters at the end…image gets uploaded.
To overcome this…I also used this method to convert these characters into valid(assumed to be accepted)::

-(NSString *)urlEncodedVersion:(NSString *)strString
{ 
    NSMutableString *strTemp = [[NSMutableString alloc] initWithFormat:@"%@",strString] ;
    NSArray *escapeChars = [NSArray arrayWithObjects:@";",@"?",@":",@"@", @"&",@"=",@"+",@"$",@",", @"[",@"]",@"#",@"!",@"’",@"(", @")",@"*",@" ",nil];

    NSArray *replaceChars = [NSArray arrayWithObjects: @"%3B",@"%3F",@"%3A",
                             @"%40",@"%26",@"%3D", @"%2B",@"%24",@"%2C",@"%5B",@"%5D", @"%23",@"%21",@"%27", @"%28",@"%29",@"%2A",@"%20",nil];

    //NSMutableString *tempStr = [[self mutableCopy] autorelease]; 
    for(int i = 0; i < [escapeChars count]; i++)
    {
        [strTemp replaceOccurrencesOfString:[escapeChars objectAtIndex:i] withString:[replaceChars objectAtIndex:i] options:NSLiteralSearch range:NSMakeRange(0,[strTemp length])];
    } 
    return strTemp;
}

but it is also not serving.

This is my whole post body::

-(void)uploadProfileInfo:(CreateProfile *)objCP
{

    NSData *imgData=UIImagePNGRepresentation([objCP userImage]);
    NSString *encodedString=[Base64Coder encodeData:imgData];

    NSString *refinedString=[self urlEncodedVersion:encodedString];

    NSString *soapMessage = [NSString stringWithFormat:

                             @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                             "<soapenv:Envelope \n"
                             "xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" \n"
                             "xmlns:tem=\"http://tempuri.org/\" \n"
                             "xmlns:wcf=\"http://schemas.datacontract.org/2004/07/NextToMe_BusinessEntity\"> \n"
                             "<soapenv:Header/>\n"
                             "<soapenv:Body>\n"
                             "<tem:CreateProfile>\n"

                             "<tem:objUser>\n"

                             "<wcf:Email>%@</wcf:Email>\n"

                             "<wcf:Mode>%@</wcf:Mode> \n"

                             "<wcf:Name>%@</wcf:Name>\n"

                             "<wcf:ProfileImage>%@</wcf:ProfileImage>\n"

                             "<wcf:RequestDateTime>%@</wcf:RequestDateTime>\n"

                             "<wcf:Status>%@</wcf:Status>\n"

                             "<wcf:StatusSpecified>%@</wcf:StatusSpecified>\n"

                             "<wcf:UDID>%@</wcf:UDID>\n"

                             "</tem:objUser>\n"

                             "</tem:CreateProfile>\n"

                             "</soapenv:Body>\n"

                             "</soapenv:Envelope>\n",[objCP email],[objCP mode],[objCP name],encodedString,@"",[objCP status],[objCP statusSpecified],[objCP UDID]];





    NSURL *url = [NSURL URLWithString:kBaseURL];               
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];             
    NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];          
    [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];       
    [theRequest addValue: @"http://tempuri.org/XXXX/CreateProfile" forHTTPHeaderField:@"Soapaction"];
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];     
    [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

    if( theConnection )
    {
        webData = [[NSMutableData data] retain];
    }
    else
    {
        NSLog(@"The Connection is NULL");
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:04:04+00:00Added an answer on May 27, 2026 at 3:04 pm

    The = characters you see at the end are padding. This is according to RFC4648 3.2. Padding of Encoded Data. The other end should be able to digest that. Apparently that is not happening. You should compare the behavior with a third party library to check whether the encoding or decoding is wrong. If you can make it work removing the padding, then good for you, but that’s a fault in the decoding library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am converting the image into thumbnail format and sending it to server and
I am converting image to NSdata using UIImageJPEGRepresentation(image, 1.0) and then encoding it to
I'm sending an http request to a server that requests an image but using
sending mail along with embedded image using asp.net I have already used following but
I am sending a image from android phone to server which is a servlet
Example: <div id=sampleimage> ***Stream or Serialize JPEG Image from Server Here w/o Sending another
Hey, I'm currently trying to send an image file to a web server using
I want to resize a image using server side script (eg: Smart Image Resizer
in a question(here Placing an image in an object, sending the object over rpc
I'm currently uploading an image to a server using Imgur on iOS with the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.