Handle file uploads within WKWebView

Hi guys,


i am new to the iOS plattform as a developer and struggeling a bit with the new WKWebView.

I made an app that handles registration and login process with nativ views and communicates via REST API with the Server.


In one View i use the WKWebView to show an Web-Interface. This is not locale on the phone. Everythings is working fine instead of a file upload.

I can choose images via camera or from the library, but after submitting the files the webview load the first page of the web interface.


I tried this with 3rd party uploaders like plupload.com or blueimp.github.io/jQuery-File-Upload ... but it never works.

The documentation of the WKWebView does not mention anything related to file handling.


So i am asking for some help in this forum.


The upload works in Safari and Chrome by the way. But the SFSafariViewController is not a possible way for me because i con not customize the view.


Thanks and sry for my poor english.

Because i had blog post where people ask for a solution but don't report the solution if they fix it.


In my case i made an mistake with the app lifecycle. So i changed the webview URL within viewDidAppear and after uploading a file this was called and loaded the base url. So i thought that the upload did not work.


Hopefully this helps others to prevent this mistake 🙂

Thank you very much,this help me a lot

Yea that was my issue too. Thanks for posting the fix.

Mine also, thanks!

Handle file uploads within WKWebView
 
 
Q