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 7247931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:04:17+00:00 2026-05-28T22:04:17+00:00

I want to upload two images to the server with following code can any

  • 0

I want to upload two images to the server with following code can any one please help me, here is my code for post data

- (void)uploadPath:(NSString*)path withOptions:(NSDictionary*)options withImageData1:(NSData*)data1 ofImageName1:(NSString *)imageName1 andImageData2:(NSData*)data2 ofImageName2:(NSString *)imageName2 {  
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    NSURL *url = [NSURL URLWithString:path relativeToURL:[NSURL URLWithString:baseURLString]];
    NSMutableURLRequest *mutableRequest = [[NSMutableURLRequest alloc] initWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:90.0];

    NSString *boundary = @"-------1234567";

    [mutableRequest setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary] forHTTPHeaderField:@"Content-Type"];
    [mutableRequest setHTTPMethod:@"POST"];
    NSMutableData *postbody = [NSMutableData data];

    for(NSString *key in options)
    {
        NSString *value = [options objectForKey:key];
        [postbody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
        [postbody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
        [postbody appendData:[value dataUsingEncoding:NSUTF8StringEncoding]];
    }   
    [postbody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];

    //*******************   Append 1st Image    ************************/

    if ([imageName1 isEqualToString:@"picture1.jpg"]) {
        [postbody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"picture1\"; filename=\"%@\"\r\n",imageName1] dataUsingEncoding:NSUTF8StringEncoding]];
    }
    [postbody appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    [postbody appendData:[NSData dataWithData:data1]];
    [postbody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    //*******************   Append 1st Image    ************************/

    //*******************   Append 2nd Image    ************************/   

    if ([imageName2 isEqualToString:@"picture2.jpg"]) {
        [postbody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"picture2\"; filename=\"%@\"\r\n",imageName2] dataUsingEncoding:NSUTF8StringEncoding]];
    }
    [postbody appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    [postbody appendData:[NSData dataWithData:data2]];

    //*******************   Append 2nd Image    ************************/

        [mutableRequest setHTTPBody:postbody];
    urlConnection = [[NSURLConnection alloc] initWithRequest:mutableRequest delegate:self];
    if (self.urlConnection) {
        self.dataXml = [NSMutableData data];
    }
    self.urlConnection = nil;
    [mutableRequest release];
    [pool release];
}
  • 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-28T22:04:17+00:00Added an answer on May 28, 2026 at 10:04 pm

    One solution to see what is wrong:

    1. make a new project, using ASIHttpRequest
    2. Get a web debugging proxy like Charles
    3. Turn on Charles (or whatever), do a multi-file upload that succeeds.
      Record data from HTTP traffic to server.
    4. Now run your own code. Record that traffic. What is different from
      your traffic to the working traffic? Makes yours IDENTICAL in all
      respects, and how can it not work?

    You can also replace step (1) with a curl command line that uploads multiple files to a server and record that traffic, but I’m not versed enough in curl to say off the top of my head what that command would look like.

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

Sidebar

Related Questions

i want to upload two files. here is the script <? ini_set('memory_limit', 400M); ini_set('file_uploads',
i have the form, and i want to upload two files. here is the
I want to upload a list of users from my work's LDAP server to
i want to upload the sound file (.ogg) in server. But it should write
I want to upload and store video files to my server using PHP. Could
I want to upload a file to a ftp server programmatically (C++). If the
I am creating code to upload images in a folder using PHP, & before
I want to file Upload The code is like this : int iTotal =
I want to divide my web application into two parts. One part is free,
I want to upload and then process a file in a Ruby on Rails

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.