0

I am working in iPhone 4.3 environment. My requirement is that I design the html page with a file upload feature, and I need to include this html file into the webview. By selecting the upload button, I need to browse my device photos and videos, so that I can upload into the server.

Is that possible? It would be really helpful if I could get any working samples.

2 Answers 2

1

It's possible.But you can not use the webkit DOM because it's not available for iOS.

My solution is:

  1. click html button, call javascript to change the value of window.location.hash e.g. window.location.hash="uploadImg;uploadUrl";

  2. using -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType to monitor the change of hash code attached to current url; if "uploadImg;uploadUrl" is found in the current url, invoke the native objective-c code to browse photo or take new picture and upload the picture to url specified by uploadUrl;

    when upload is done, native code could call javascript by

    NSString *markupResult = [webView stringByEvaluatingJavaScriptFromString:@"callback_javascript_upload()"];

Sign up to request clarification or add additional context in comments.

Comments

0

It's possible to do what you looking for.

In your html code , your upload button should call javascript that will call your browsing photos and video objective-c code

The technique is calling objective-c code from javascript , see also : WebKit DOM Programming Topics here.

2 Comments

Hi, Thanks for your response, it will be very helpful, if any samples available to proceed further.
The link above is enough more or try to custom with your code look up there tetontech.wordpress.com/2008/08/14/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.