Upload a photo using UIWebView

Suppose I have a web page (say filebrowse.html) on a remote server, with a browse file button, I want to access this page through UIWebView and upload a photo from my gallery. (The gallery is on the iPhone.)

Is it possible?

+2
source share
3 answers

In iOS, there is no way to "view the file system", so you cannot use the form in UIWebView to attach photos for upload. The answer is rather confusing, but here it is:

You will need to -

  • UIImagePickerController to get a snapshot from a photo album.
  • Define POST headers for the submit form
  • Encode image as NSData li>
  • Write a POST request with NSURLConnection when an NSData object is inserted in the appropriate header

I cannot give you the code for all this because it needs to be broken down into all these steps.

+1
source

HM interesting. Have you tried accessing this page in your own Safari? Will you be able to view the phone? If not (and I assume you are building the application here), you can simply use POST for the form in question (use curl and the web browser inspector to find out the options you need, etc.).

0
source

maybe this will help you show how to select a photo from a web browser without using <input type="file" /> in <form></form>

0
source

All Articles