0

I try to POST images to server. I have finished it successfully like this:

I have webView, catch "right" url and switch viewControllers. After switch them I choose image from PhotoLibrary or from camera, POST it and switch controllers back.
P.S. As u know, in mobile safary(in webview too) all "choose" buttons on sites are disabled.

I think that it isn't straightforward way, so..
My question: Can I choose images from webview's button "choose"? I want to choose images on iDevices similar PC without another viewControllers.

I'm newbie in programming, but I have some ideas(don't know how to realize them):
1.Upload image to DOM. And use "save" button on webView.
2.Add button with selector(can I?) to webView with Javascript. And handle this selector.(smth like that) I saw similar thing for toolbar item.

kaspartus
  • 1,365
  • 15
  • 33

1 Answers1

0
  • Get the image. Convert in to a base64 string (http://stackoverflow.com/questions/3889478/uiimage-to-base64-string-encoding)
  • Put this string inside the value of a hidden input.
  • Submit the form.
  • On the server convert the base64 back to binary and save to file/DB.

(PS. File inputs are not supported in iOS safari. The choose button is just there as a placeholder, to not break any layouts. There is absolutely no code behind the element, so there is no way try to get it to work.)

Gerben
  • 16,747
  • 6
  • 37
  • 56