我正在尝试下载一个word文档,该文档是从我web服务接收的base64字符串。
在我的html页面上,我要求用户输入一些数据来填充word,当用户单击一个按钮时,我想要下载word文档。
按钮-->发送到web服务-->创建word文档-->发送回base64 -->将此base64下载为word文档
我正在使用Downloadify在IE9中实现这一点
问题是Downloadify询问加载页面上的文件名和数据。只有在用户在同一页面上输入数据后,我才能获得这些信息。
Downloadify.create('downloadify', {
filename: filename,
data: data,
onComplete: function () {
alert('Your File Has Been Saved!');
},
onCancel: function () {
alert('You have cancelled the saving of this file.');
},
onError: function () {
alert('You must put something in the File Contents or there will be nothing to save!');
},
transparent: false,
swf: 'js/lib/Downloadify/media/downloadify.swf',
downloadImage: 'js/lib/Downloadify/images/download.png',
width: 100,
height: 30,
transparent: true,
append: false
});有没有办法绑定文件名和数据?或者我应该添加另一个页面,它已经获取了所有数据,并且只要求“保存到磁盘上”?
发布于 2016-02-03 06:10:06
你也许可以使用生命,例如:
filename: (function(){return $('#file-name-input').val();}())
我假设Downloadify只会在文件保存时执行查找,即使它需要提前声明。
否则,在填写并确认必要的文本框之前,不要运行Downloadify.create(),它会生成下载按钮。
顺便说一句,在Downloadify文档中,他们提到允许你让data属性指向一个函数。一个例子就是
`data: function() { return "data that comprises the file contents"; }`https://stackoverflow.com/questions/30186914
复制相似问题