请问网页上怎样不用input="file"来上传文件,就比如像163邮件上传附件的那个样子?

来源:百度知道 编辑:UC知道 时间:2024/05/20 14:37:59
最好是javascript、jsp解决方案。
asp的不要。
如果非要用input type=“file”,用什么方法可以设需要的属性值给它?
<br>我现在的输入页面有好几个,input属性值需要在几个页面间传递,最后才一起提交。

那个是隐藏在页面中的iframe包含的input="file"实现上传的,实际还是用input="file"就实现上传文件。
这种方式需要三个页面,前台按钮页面,隐藏的iframe页面,后台接收处理的页面。隐藏的iframe代码只包括一个<form>,form中包含input=file的代码。通过前台页面的一个按钮input=button来操作iframe页面form中的input=file,达到设置input=file属性值的目的。
前台核心JS代码:(iframe_upload是iframe的name,upfiles是iframe页面中input=file的id,form_upload是iframe页面中form的id。)
var bt = iframe_upload.document.getElementById('upfiles');
bt.click();
if ( bt.value.length > 0 )
{
iframe_upload.document.getElementById('form_upload').submit();
}
后台页面就是通用的POST接收文件的程序就可以了