如何在没有用户看到“浏览”的情况下为上传功能提供文件路径对话

编程入门 行业动态 更新时间:2024-10-09 19:23:54
本文介绍了如何在没有用户看到“浏览”的情况下为上传功能提供文件路径对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用MFC c ++应用程序,我将IE Web浏览器控件嵌入到对话框中。我已经连接到控件的浏览器事件,我正在调用SetUIHandler来提供我自己的IDocHostUIHandler实现。我还实现了 SetExternal,因此我可以为特定网页提供自定义API,以便它们可以与我的应用程序进行互操作。

I am using a MFC c++ application where I embed the IE web browser control in a dialog box. I have connected up to the control's browser events and I am calling SetUIHandler to provide my own implementation of IDocHostUIHandler. I am alsoimplementing SetExternal so I can provide a custom API for specific web pages so they can interoperate with my application.

此互操作的一部分是提供文件上载功能  ;在我们的MDI应用程序中工作的用户可以通过该命令运行将上载其当前文件的命令。我导航到的网站目前拨打电话获取文件名,当然用户会看到控件显示的浏览对话框。用户浏览文件并选择它,然后文件进入网站。很酷。

Part of this interoperation is to provide file uploading capabilityby which a user that is working in our MDI application can run a command that will upload their current file. Theweb site I navigate to currently makes a call to get a filename and of course the user sees the browse dialogthe control brings up. The user browses to the file and selects it and up the file goes to the website. Cool.

但是,我想避免实际的浏览对话框并透明地向用户提供文件路径,因为我们的应用知道文件所在的位置(我确保文件是在客户端计算机上使用操作系统命名空间功能到创建一个zip文件,其中包含zip文件中的应用程序文件。)

However, I would like to avoid the actual browse dialog and supply thefilepath transparently to the user sinceour app knows where the file resides (I make sure the fileis on the client machine and use theOS namespace capability to create a zip file with the applicationdocument in the zip file).

网络程序员告诉我,我不能只是将文件路径作为参数传递给页面(安全问题。)我也不能使用我的调度(外部)对象传递他们的javascript文件路径。我找到了IDocHostShowUI接口,但我没有看看我如何拦截浏览对话框UI并返回浏览器控件的文件名,这样用户就不会费心找到我要上传的实际文件。

The web programmers tell me that I cannot just pass the file path as a parameter to the page (security problems.)Nor can I use my dispatch (external) object to pass their javascript the file path. I have found the IDocHostShowUI interface but I don't see how I would intercept the browse dialog UI and return the browser control the filename so the user isn't bothered with finding the actual file I will upload.

在完成所有背景之后,我的问题很简单:

After all that background, my question is simple:

有没有办法让我提供以编程方式上传的文件名,这样用户就不会看到浏览用户界面?

Is there a way for me to give to provide the filename to be uploaded programmatically so the user does not see a browse UI?

RD Holland

R.D. Holland

推荐答案

创建您自己的http请求并通过WinInet或WinHttp发送。在没有提示的情况下自动化IE上传文件的能力被认为是安全漏洞并在IE 8中被删除。 Create your own http request and send via WinInet or WinHttp. The ability to automate IE to upload a file without a prompt is considered a security hole and removed in IE 8.

更多推荐

如何在没有用户看到“浏览”的情况下为上传功能提供文件路径对话

本文发布于:2023-10-29 00:32:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1538206.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   情况下   上传   功能   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!