如何在没有用户看到“浏览”的情况下为上传功能提供文件路径对话 [英] How do I supply a file path for the upload capabiltiy without the user seeing a "browse" dialog

查看:74
本文介绍了如何在没有用户看到“浏览”的情况下为上传功能提供文件路径对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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 also implementing 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 capability by which a user that is working in our MDI application can run a command that will upload their current file. The web site I navigate to currently makes a call to get a filename and of course the user sees the browse dialog the 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 the filepath transparently to the user since our app knows where the file resides (I make sure the file is on the client machine and use the OS namespace capability to create a zip file with the application document 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.


这篇关于如何在没有用户看到“浏览”的情况下为上传功能提供文件路径对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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