如何在iPad上的UIWebView中上传文件? [英] How to upload files in a UIWebView on an iPad?
问题描述
我正在开发一个iPad应用程序,我的应用程序的一个组件有一个UIWebView,其网页上有一个浏览按钮来上传文件(在这种情况下是照片)。
Im developing an iPad app, and one of the components of my app has a UIWebView with a web page that has a browse button to upload a file (in this case, photos).
我知道应用程序无法访问文件系统,但我已经在App Store上看到了通过照片实现此功能的应用程序。很多都是为iPhone编写的。
I am aware that apps cannot access the filesystem, but I have seen apps on the App Store that achieve this functionality with photos. Alot of these are written for the iPhone.
我不想使用第三方应用程序来获得此功能,我想将此功能嵌入到我的应用程序中。
I don't want to use a third party app to get this functionality, I want to embed this functionality into my app.
我已经完成了搜索,无法找到任何关于此的开发信息。
I've already done a through search and can't find any development info on this.
任何人有任何建议吗?
推荐答案
在iOS5及更早版本的网页视图中无法上传文件(这可能会受到支持) iOS6,但我无法对未发布的测试版功能发表评论; - )。
There is no way to upload files within a web view on iOS5 and earlier (this might be supported in iOS6, but I couldn't possibly comment on unreleased beta functionality ;-).
您看到的这样做的应用几乎肯定是使用原生图像实现功能选择器控件,而不是HTML文件上传字段。
The apps you have seen that do this are almost certainly implementing the functionality using a native image picker control, not an HTML file upload field.
如果您已经在Web视图中看到了这些功能,那么他们可能已经使用webview委托进行通信从Web视图返回到本机代码并触发本机映像选择器。然后,可以使用JavaScript将图像数据作为base64编码数据URL传回Web视图。
If you have seen the functionality working from within a web view, what they may have done is used the webview delegate to communicate back from the web view to the native code and triggered a native image picker. The image data can then be passed back to the web view as a base64 encoded data URL using JavaScript.
这篇关于如何在iPad上的UIWebView中上传文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!