Take picture with iPhone API and transfer it to a server

I have written an cocoa application to take a picture on the iPhone. I need to transfer the images taken to somewhere besides the iPhone namely another server. Does anyone know how I can accomplish this?

Thanks, Joe


First get a server and figure out what kind of phone <---> server API you want to use. There are any number of ways it can work. A simple and common scheme is a REST API with photos being uploaded via HTTP POST.

The basic scheme would be something like:

  • Take picture
  • Convert to JPG (there's a function for this)
  • Construct HTTP POST using the NSURL* classes
  • Set JPG data as POST body (or one part of a mutipart form post)
  • Converting to base64 should not be necessary.

    If you've never put together any kind of server API, there are any number of examples available. Most photo-sharing sites have public APIs which may be useful references.


    By far the easiest way is to use an HTTP POST . Take a look at the "URL Loading System" in your documentation and then examine the related classes, particularly NSURLRequest .


    As other people say, use HTTP POST. ASIHTTPRequest makes wrapping your POST up simple. It also moves your upload to a background thread and gives your delegate progress updates.

    链接地址: http://www.djcxy.com/p/66518.html

    上一篇: 使用自定义名称将照片保存到iphone相机胶卷

    下一篇: 用iPhone API拍照并将其传送到服务器