一个文件上载字段作用于两个提交表单 [英] One file upload field acting on two submit forms

查看:69
本文介绍了一个文件上载字段作用于两个提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


这最初发布在HTML部分,但有人建议我将它发布在JavaScript部分,所以这里是...


我在表单中包含一个文件上传框,用于动态更新下拉内容。


我有第二个表单我用它来提交与表单1中使用的文件相同的文件。但是,我已经进行了设置,以便在下拉更新后删除上传的文件 - 然后在提交按钮时重新上传此文件单击第二个表单。这显然最小化了文件在服务器上的时间,因此降低了第三方可能看到此数据的可能性。


是否可以只有一个文件上传框....在form1中,并使用此上传框作为表单2的输入?


PS:表格不是嵌套的。


谢谢!

Hi all,

This was originally posted on the HTML section, but it was suggested that I post it in the JavaScript section, so here it is...

I have a file upload box contained within a form which I use to dynamically update the contents of a drop down.

I have a second form just below which I use to submit the same file as used in form 1. However, I have set things up so that the uploaded file is deleted after the drop down has been updated - then this file is re-uploaded when the submit button in the second form is clicked. This obviously minimizes the time the file is on the server, so reduces the possibility a third party might see this data.

Is it possible to just have one file upload box.... in form1, and use this upload box as input for form 2 as well?

P.S: The forms are not nested.

Thanks!

推荐答案

可以采用几种方法。


其中一个是:
  • 添加这是第二种形式。[html]< div style =" display:none;">< input type =" file"名称= QUOT; ----" id =" secondFile">< / div> [/ html]
  • 将其添加到第一种形式的文件标记中。[html]< input type = "文件"名称= QUOT; ----" onchange =" document.getElementById(''secondFile'')。va lue = this.value;"> [/ html]





感谢您的建议。在FF2中工作得很好,但在IE6和Safari中不起作用。下面是我正在使用的代码。任何使浏览器更兼容的建议都会很棒。

Hi,

Thanks for the suggestion. Works great in FF2, but doesn''t work in IE6 and Safari. Below is the code I''m using. Any suggestions to make it more browser compatible would be great.

展开 | 选择 | Wrap | 行号


它也应该在IE中工作。如果不能正常工作,代码的其他部分可能会出现问题。


但我对你想做的事情有点困惑。如果你想两次上传同一个文件,为什么不在服务器端脚本中进行一些更改以将文件复制到两个位置而不是创建两个表单?
It should work in IE too. If not working, there might be some problem with some other part of code.

But I am a bit confused about what you want to do. If you want to upload same file twice, why don''t you make some changes in server side script to copy the file to two locations rather than creating two forms?


这篇关于一个文件上载字段作用于两个提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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