可以这样,button里写 window.open('xxx.php?fileName=aaaa'),然后这个php文件里根据这个fileName找到对应文件,然后在这个页面以文件流的形式输出到浏览器端,这样会生成保存文件对话框
我是搞C#的,C#的文件流输出到浏览器代码如下
stream = File.Open(filePathName, FileMode.Open, FileAccess.Read)byte[] data = new byte[stream.Length]
int result = stream.Read(data, 0, data.Length)
if (!File.Exists(filePathName))
return
HttpContext.Current.Response.Buffer = true
HttpContext.Current.Response.Charset = Encoding.UTF8.ToString()
敬神 HttpContext.Current.Response.AddHeader("Content-Disposition", "inlinefilename="州察 + Server.UrlEncode(fileName))
HttpContext.Current.Response.AddHeader("Content-Length", data.Length.ToString())
HttpContext.Current.Response.ContentType = "application/ms-excel"
stream.Close()
File.Delete(filePathName)
Response.BinaryWrite(data)
亮迹亏 HttpContext.Current.ApplicationInstance.CompleteRequest()
这是典型的返敬余笑回信息的格式或编码的问题。要想解决这个问题,最简单的办法是使用network标亮含签对返回数据进行抓包,查看下返回毁旅的字符串的内容,推测里面含有肉眼不可见的字符。
不要在编程序的软件中打开,直接用迅岩浏览器打开,也许可以,还有,如果还不行把<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional/纤誉/EN">删掉试试。
<script type="text/javascript">毁昌段
Ext.onReady(function() {
Ext.msg.alert("1111111111111111111111")
})
</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)