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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:48:21+00:00 2026-05-11T18:48:21+00:00

I am currently uploading images to my server via HTTP POST. Everything works fine

  • 0

I am currently uploading images to my server via HTTP POST. Everything works fine using the code below.

NSString *UDID = md5([UIDevice currentDevice].uniqueIdentifier);
NSString *filename = [NSString stringWithFormat:@"%@-%@", UDID, [NSDate date]];
NSString *urlString = @"http://taptation.com/stationary_data/index.php";
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 *postbody = [NSMutableData data];
[postbody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@.jpg\"\r\n", filename] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[postbody appendData:[NSData dataWithData:imageData]];
[postbody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postbody];

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

However, when I try to convert this to work with Image Shacks XML API, it doesn’t return anything. The directions from ImageShack are below.

Send the following variables via POST to imageshack. us /index.php

fileupload; (the image)
xml = "yes"; (specifies the return of XML)
cookie; (registration code, optional)

Does anyone know where I should go from here?

  • 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-11T18:48:21+00:00Added an answer on May 11, 2026 at 6:48 pm

    You might want to consider using ASIHTTPRequest, as it will build a form data post body for you with a lot less hassle, and can stream the request body from disk, so you’ll save memory when uploading large images.

    A quick google found this, which seems to suggest you should be posting to /upload_api.php rather than /index.php.

    Something like this would probably be a good start:

    ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithUrl:[NSURL URLWithString:@"http://www.imageshack.us/upload_api.php"]] autorelease];
    [request setFile:@"/path/to/file" forKey:@"fileupload"];
    [request setPostValue:@"yes" forKey:@"xml"];
    [request setPostValue:@"blahblah" forKey:@"cookie"];
    //It looks as though you probably need these too
    [request setPostValue:@"me@somewhere.com" forKey:@"email"];
    [request setPostValue:@"blah" forKey:@"key"];
    [request start];
    if ([request error]) {
        NSLog(@"%@",[request error]);
    } else {
        NSLog([request responseString]); // The xml that got sent back
    }
    

    Warning: untested!

    I’ve used a synchronous request because you did, but you almost certainly should be using an asynchronous request instead (a queue with ASIHTTPRequest).

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

Sidebar

Related Questions

Iam using below code for uploading images on the remote server.When I use below
Im currently uploading data to MS SQL server via SQLBulkCopy and Transactions. I would
I am currently looking in to some file uploading using Java Server Faces. I've
I am currently uploading images pasted from the clipboard with the following code: //
I'm currently uploading an image to a server using Imgur on iOS with the
The upload script in this page is currently uploading the images to the same
I am uploading large files to an ASP.NET server using a standard HTML <input>
What's the most efficient way to resize large images in PHP? I'm currently using
I'm currently writing an upload class for uploading images. I do extension checks to
Currently, I am uploading PDF files, and images from my MVC web application to

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.