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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:48:42+00:00 2026-05-27T00:48:42+00:00

I am facing issues in uploading media files to a web service built in

  • 0

I am facing issues in uploading media files to a web service built in php.
I have an app along with source code in android and I am suppose to replicate it in iphone.
There is this part where I am supposed to upload media files along with some strings to a web service.
The code in android uses a class called MultiPartEntity and HTTPPost to upload it.
There are several tags , and the tags are associated with some strings.

for ex.MultiPartEntity mpEntity.addPart(“username”, “abc”);, similarly for password and other tags.

I made some research and I found ASIFormDataRequest which deals with similar things.

here is the sample code I am using to upload media along with some other detials,

NSData *imageData = UIImageJPEGRepresentation(image.image, 90);
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:@”http://my.url.com/somephpwebservice.php”%5D%5D;
[request setHTTPMethod:@”POST”];

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

// now lets create the body of the post 
NSMutableData *body = [NSMutableData data];

//................................ Append the image data here//u= \"TP\";p= \"7012\";o= \"DEMO\";j= \"1151\"...........................
//if (!([htmlCodeToWrite rangeOfString:@"SignatureShouldBeDoneHere"].location == NSNotFound))
//{
    [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];    
    [body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data;name=\"userfile\";username=\"TP\";p=\"7012\";filename=\"%@\"\r\n",@"superman.jpg"] dataUsingEncoding:NSUTF8StringEncoding]];
    //[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[@"Content-Type: image/jpeg\r\n\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
    [body appendData:[NSData dataWithData:imageData]];
//}
//NSString *content = [NSString stringWithUTF8String:[imageData bytes]];
NSLog(@"%@",imageData);
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];

//data into the string..... verifying............
NSString *strTest = [[NSString alloc] initWithData:body encoding:NSASCIIStringEncoding];
NSLog(@"%@ %@",@".....the request for webService",strTest);

// setting the body of the post to the request
[request setHTTPBody:body];

// now lets make the connection to the web
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];

NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

NSLog(@"%@ %@",returnString,@".....the response from webService");

Is this the proper procedure.??

The php developer says the image is not getting uploaded.

Please help.
Thanx in advance.

  • 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-27T00:48:43+00:00Added an answer on May 27, 2026 at 12:48 am

    Please refer to my response in this post. I think is the correct way to conform a multipart upload file request. Cheers!

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

Sidebar

Related Questions

I'm facing scalability issues in Android WebView. My code is correct and I'm even
I am working on a Google App Engine application, and have been facing some
I've been facing issues with my installation of Android sdk on my MAC. As
I have a page on iPad and am facing some issues implementing an equivalent
I'm facing issues with implementing WebView in Android. I've followed all the details provided
As we are facing GWT performance issues in a mobile app I peeked into
Currently I am facing issues, that the java melody statistics running for a grails
I am facing some issues while serializing objects (I am using JBoss Drools, and
Well, since I am facing some issues with OAuth implementation, I decided to go
I'm working using scriptaculous library. However I'm facing some issues with inclusion of 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.