通过windows mobile app webview组件上传文件 [英] Upload file through windows mobile app webview component

查看:72
本文介绍了通过windows mobile app webview组件上传文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发Windows移动应用。在移动应用程序中,我们在webview组件中拥有大部分功能。我们有上传图片的功能。



我们使用HTML文件标签浏览和上传图片。单击浏览选项时,我们已设法打开库。但是,我们无法上传图像并将所选文件传输到webview中。



是否有人知道任何解决方法或遇到类似问题并找到任何替代方案?



任何建议都非常有帮助。



谢谢



我尝试了什么:



我们尝试创建一个带上传文件标签的简单html表单。但这也行不通。

解决方案

Windows Phone的 WebView 可能不会自行上传文件 - 请参阅此处,无法从Webview内部上传文件? [ ^ ]。也许微软不希望用户使用WebView上传内容。



另一种方法是使用你自己的 HttpClient 对象,然后通过以下方式将文件上传到该Uri:将其编码为多部分表单数据。如果您处理JavaScript代码,例如 btn.onclick = uploadFile(); ,可以从那里发出POST请求,知道URL或Uri就可以轻松上传文件。微软锁定了文件上传,令我感到震惊。 :笑:



HttpClient类 - UWP app开发者| Microsoft Docs [ ^ ]

We are working on windows mobile App. In mobile App, we have majority of functionality in webview component. We have a functionality for uploading image.

We have used HTML File tag for browse and upload image. When clicking on Browse option, we have managed to open the gallery. however, we are unable to upload the image and transfer the selected file into webview.

Does any one knows any workaround or faced similar kind of problem and found any alternatives?

Any suggestions in this will be really helpful.

Thank you

What I have tried:

We have tried by creating a simple html form with upload file tag. But that too doesn't work.

解决方案

Windows Phone's WebView perhaps does not file upload itself — see here, File uploading not possible from inside a Webview?[^]. Maybe Microsoft did not want users to upload the content, using WebView.

An alternate to this would be to use your own HttpClient object and then upload the file to that Uri by encoding it to multipart form data. POST request can be issued from there, and knowing the URL or Uri you can easily upload the files, if you handle the JavaScript code such as btn.onclick = uploadFile(); etc. It comes to me with a shock, that Microsoft locked out file uploads. :laugh:

HttpClient class - UWP app developer | Microsoft Docs[^]


这篇关于通过windows mobile app webview组件上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆