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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:47:56+00:00 2026-06-06T22:47:56+00:00

Is it possible to upload two (or more) files in only one request?? I’ve

  • 0

Is it possible to upload two (or more) files in only one request??

I’ve been trying to do so with NSMutableURLRequest and NSURLConnection but no success so far, and I have found no convincing answers online.

It’s easy to upload a single file (using code from here) but the HTML Specs mention that when uploading more than one file you have to embed a multipart/mixed header inside the multipart/form-data, and the files to be uploaded within that multipart/mixed header.

The problem with the code linked above is that the one file that is being uploaded has it’s Content-Disposition set to “form-data” (I guess that means that the single file is “all” of the form’s data?) which I think leaves “no room” to attach another file. Please correct me if i’m wrong.

Thanks.

  • 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-06-06T22:47:58+00:00Added an answer on June 6, 2026 at 10:47 pm

    EDIT:

    The file data you are uploading should be encoded using Base64; you can do that by means of NSData+Base64 and then use:

    [body appendData:[imageData1 base64EncodedString];
    

    to send the file data, whereby I assume that imageData1 was defined as:

    NSData* imageData = UIImagePNGRepresentation(image);
    

    and image is a UIImage.

    OLD ANSWER:

    This is an example coming from the HTML 4.0.1 standard (very end of the document):

    Content-Type: multipart/form-data; boundary=AaB03x
    
    --AaB03x
    Content-Disposition: form-data; name="submit-name"
    
    Larry
    --AaB03x
    Content-Disposition: form-data; name="files"
    Content-Type: multipart/mixed; boundary=BbC04y
    
    --BbC04y
    Content-Disposition: file; filename="file1.txt"
    Content-Type: text/plain
    
    ... contents of file1.txt ...
    --BbC04y
    Content-Disposition: file; filename="file2.gif"
    Content-Type: image/gif
    Content-Transfer-Encoding: binary
    
    ...contents of file2.gif...
    --BbC04y--
    --AaB03x--
    

    Notice that the files are listed all together in a multipart/mixed list.

    So you can try with the code:

    //-- new part in multipart/form-data
    [body appendData:[[NSString stringWithFormat:@"--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"Content-Disposition: form-data; name=\"files\" dataUsingEncoding:NSUTF8StringEncoding]];
    
    //-- new multipart/mixed
    [body appendData:[[NSString stringWithFormat:@"multipart/mixed; boundary=%@", mixedBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
    
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: file; filename=\"%@\"\r\n", FileParamConstant1] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:@"Content-Type: image/jpeg\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:imageData1];
    [body appendData:[[NSString stringWithFormat:@"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    
    
    [body appendData:[[NSString stringWithFormat:@"--%@\r\n", mixedBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
    
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: file; filename=\"%@\"\r\n", FileParamConstant2] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:@"Content-Type: image/jpeg\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:imageData2];
    [body appendData:[[NSString stringWithFormat:@"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    

    Take care of changing the filename and name attributes and it should work.

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

Sidebar

Related Questions

Is it possible to upload multiple files direct to Amazon S3 from a browser
Currently in my application I have two possible textboxes. One for a local image
We've got two servers. First one is fast but has limited capacity and bandwidth.
I am trying to implement the simplest shared 'files' folder for a website but
Is it possible to upload images using Scribe-Java and twitter POST Url https://upload.twitter.com/1/statuses/update_with_media.json? my
Is it possible to upload a specific part of the file rather than the
Is it possible to upload a file to another server or pass a file
is it possible to upload a file and subsequently when receiving response download the
Is is possible to upload a photo to facebook using Corona?
Is it possible to upload an audio file (i.e. mp3, flac...) to the 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.