如何在iPhone SDK中将文件上传到服务器? [英] How to upload a file to the server in iPhone SDK?

查看:133
本文介绍了如何在iPhone SDK中将文件上传到服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在iPhone中向服务器发送文件。是否有任何iPhone API来实现该功能?

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

推荐答案

ASIHTTPRequest 是网络API的包装器,可以非常轻松地上传文件。
这是他们的例子(但你也可以在iPhone上执行此操作 - 将图像保存到磁盘,然后上传它们。

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"];

这篇关于如何在iPhone SDK中将文件上传到服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆