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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:37:29+00:00 2026-05-22T18:37:29+00:00

I am trying to send images and text from an iPhone application to a

  • 0

I am trying to send images and text from an iPhone application to a asp.net webpage.

By following this example I now have the following method in xcode for uploading an image:

- (BOOL) uploadData {
    NSData *imageData = UIImageJPEGRepresentation([serviceForm image], 0.9);
    NSString *urlString = @"http://someUrl/SubmitSchema.ashx";
    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    [request setURL:[NSURL URLWithString:urlString]];
    [request setHTTPMethod:@"POST"];

    NSString *boundary = @"---------------------------14737809831466499882746641449";
    NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
    [request addValue:contentType forHTTPHeaderField: @"Content-Type"];

    NSMutableData *body = [NSMutableData data];
    [body appendData:[[NSString stringWithFormat:@"--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];

    [body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"ipodfile.jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];

    [body appendData:[NSData dataWithData:imageData]];

    [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];

    [request setHTTPBody:body];

    NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
    NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

    BOOL success = [returnString isEqualToString:@"ok"];
    [returnString release];

    return success;
}

At the bottom on the same article there is a suggestion about creating an asp.net generic handler. Based on this, I have the following simple code for saving the image:

public void ProcessRequest(HttpContext context)
{
    context.Response.ContentType = "text/plain";
    foreach (var name in context.Request.Files.AllKeys)
    {
        var file = context.Request.Files.Get(name);
        SaveFile(file);
    }
}

private void SaveFile(HttpPostedFile file)
{
    var fileName = Path.GetFileName(file.FileName);
    var path = "C:\\Test\\" + fileName;

    file.SaveAs(path);
}

This works and the image is saved, but I have not yet managed to include a string of text in the same post. The text I want to send can be quite long, and I suppose it is better to include this in the posted data rather than as a query string?

How would you add some text to the posted data and read it in .net?

  • 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-22T18:37:30+00:00Added an answer on May 22, 2026 at 6:37 pm

    I’m not an Objective-C expert but from a little Googling I found a discussion and a working example of sending a file and form fields in a single request.

    On the server, you can pull the data out again on the other side using:

    string data = Request.Form["name"];
    

    If you get stuck, Fiddler is a great tool for sniffing HTTP requests.

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

Sidebar

Related Questions

I have been trying to send .png images from iPhone to web service. I
I am trying to send an image from a Java desktop application to a
I am trying to extract specific content(links, text, images) from an HTML page. Is
Im trying to send images over HTTP using HttpListener but some images come from
I am trying to send an email from a site I am building, but
i'm trying to send fake keyboard input to an application that's running in a
I am trying to send some data from a LINQ query in C# to
I'm trying to send email with some images attached in django. Code used is
I am trying to send an email message with data collected from an html
I have written C# code for ascx. I am trying to send an email

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.