FileUpload控件本身清除 [英] FileUpload control clears itself

查看:149
本文介绍了FileUpload控件本身清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些麻烦的FileUpload控件,想知道如果我能得到一些帮助。

I'm having some trouble with the FileUpload control and was wondering if I could get some help.

在我的网页我有一个FileUpload控件和一个下拉列表中。

On my page I have a FileUpload control, and a drop down list.


所以用户浏览到他们想要的文件,然后选择从下拉菜单(这使一些复选框也都在页面上使用,这取决于他们在下拉菜单中选择关闭)一个选项。这将导致FileUpload控件成为空的,现在用户必须浏览到他们再次想要的文件。

So the user browses to the file they want, and then select an option from the drop down (which enables some checkboxes that are also on the page for use, depending on what they select in the drop down). This causes the FileUpload control to become empty, and now the user must browse to the file they wanted again.

反正是有prevent从回传过程中丢失其内容FileUpload控件?

Is there anyway to prevent the FileUpload control from losing its contents during the PostBack?

推荐答案

既然你试过Relster的建议,并没有工作,斯宾塞是正确的。输入类型=文件/>由于安全问题,但任何东西,但浏览器设置在&lt路径是不可能的;元件。唯一的解决办法是,当你要提交文件进行重组流动,使唯一的回发完了,做任何其他操作使用客户端脚本。

Since you tried Relster's suggestion and it didn't work, Spencer is correct. Due to security concerns, it is impossible for anything but the browser to set the path in an <input type="file"/> element. The only solution is to restructure the flow so that the only postback is done when you want to submit the file, and do any other manipulation with client side scripting.

您不能设置路径的原因是因为它允许你来窃取用户的文件。例如,如果你隐藏输入,并有回发一个无辜的看着按钮,你可以在文件输入的默认路径设置到任何你想获得访问,用户会上传却没有意识到发生了什么事情。

The reason you cannot set the path is because it would allow you to steal users' files. For example, if you hide the input, and have an innocent looking button for postback, you could set the default path of the file input to whatever you wanted to get access to, and the user would upload it without ever knowing what's going on.

这篇关于FileUpload控件本身清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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