Upload a photo using UIWebView

后端 未结 3 1638
南方客
南方客 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:13

    may this will help, it shows you how to choose a photo from webview without using <input type="file" /> in <form></form>

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-07 03:33

    Hmm - interesting. Have you tried accessing that page in native Safari? Will it let you browse on the phone? If not (and I'm assuming you're building an app here) you can just use a POST to the form in question (use curl and a browser web inspector to figure out parameters you need, etc).

    0 讨论(0)
提交回复
热议问题