[英]How to upload a file to the server in iPhone SDK?
I want to send a file to server in iPhone. 我想将文件发送到iPhone中的服务器。 Is there any iPhone API to implement that functionality?
是否有任何iPhone API可以实现该功能?
ASIHTTPRequest is a wrapper around the network APIs and makes it very easy to upload a file. ASIHTTPRequest是网络API的包装器,使上传文件非常容易。 Here's their example (but you can do this on the iPhone too - save images to "disk" and later upload them.
这是他们的示例(但您也可以在iPhone上执行此操作-将图像保存到“磁盘”,然后上传。
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"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.