Upload a photo using UIWebView

后端 未结 3 1665
南方客
南方客 2021-01-07 03:05

Suppose I have a web page (say filebrowse.html) in a remote server, having a browse file button, I want to access this page via a UIWebView and upload photo fro

3条回答
  •  甜味超标
    2021-01-07 03:24

    On iOS, there is no way to "browse the filesystem" so you can't use a form in UIWebView to attach photos for upload. The answer is rather convoluted but here goes:

    You're going to have to -

    1. UIImagePickerController to get a picture from the photos album.
    2. Determine the POST headers for the submit form
    3. Encode the image as NSData
    4. Write a POST request with NSURLConnection with the NSData object getting inserted in the proper header

    I can't really give you the code for all of this because it needs to be broken down into all of those steps.

提交回复
热议问题