开发者

sending files from iphone app to a local server?

Need some help please with web related matters since I don't know much about web (more on the software side of things).

Basically,开发者_StackOverflow中文版 I am developing an iphone app and would like to send data to a local server once in a while (for simplicity, let's just say I want to send this info to my personal computer which will act as the server). This is just some simple data, and I dont care about the format (actually .txt is the best, but I am open to any format which will make it easier - I am just transferring numbers).

What would be the best way to go about this process? A quick step by step explanation would be highly appreciated. From my very basic knowledge I assume that I will need to:

  1. setup my Mac as a server (which I think should be done from settings?)
  2. Create a URL connection on my app and send the file?

I am probably missing 50 other steps here...

Thanks!


One path is to set up a webDAV server -- you'll have to Google that up, it's far too big a topic to cover here.

To the specific questions you asked:

1) Your mac can become a web server by turning on the WebSharing in preferences, or a file server by turing on fileSharing. Be sure to set permissions the way you want them.

2) If your mac is a web server, you could write a simple CGI script (perl, ruby, or the like -- this is simple tutorial stuff that's all over the www) that accepts your text as a parameter. From your iPhone app, you'd make an NSURLRequest to a URL similar to:

http://192.168.10.1/webPage.html?this+is+the+text+I+want+to+send

Of course, you can get fancier ans use POST requests (the above example is a GET request), but that's going to require more reading.

If you want to transfer files via file sharing, that's a bit more complicted.

What would REALLY help us answer is if you could specify the question a bit more tightly. As it is, you've asked about a very broad area that covers quite a bit of ground.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜