I want to send a file to server in iPhone. Is there any iPhone API to implement that functionality?
Asked
Active
Viewed 4,643 times
2 Answers
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
-
1I second this opinion - ASIHTTPRequest is a good wrapper to be used in this sittuation. – Moszi Feb 16 '11 at 09:57
2
-
1This 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