3

I want to send a file to server in iPhone. Is there any iPhone API to implement that functionality?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Nilesh
  • 1,493
  • 18
  • 29

2 Answers2

5

ASIHTTPRequest is a wrapper around the network APIs and makes it very easy to upload a file. Here's their example (but you can do this on the iPhone too - save images to "disk" and later upload them.

ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:url] autorelease];
[request setPostValue:@"Ben" forKey:@"first_name"];
[request setPostValue:@"Copsey" forKey:@"last_name"];
[request setFile:@"/Users/ben/Desktop/ben.jpg" forKey:@"photo"];
shinynewbike
  • 2,334
  • 5
  • 28
  • 42
  • 1
    I second this opinion - ASIHTTPRequest is a good wrapper to be used in this sittuation. – Moszi Feb 16 '11 at 09:57
2

This tutorial will let you upload files to server

Pankaj Kainthla
  • 2,439
  • 5
  • 31
  • 61
  • 1
    This solution is adequate for small posts only as it stores the complete post in the memory until it is sent. If this is not a possibility then the the ASIHTTPRequest wrapper could be used instead. – Moszi Feb 16 '11 at 10:02