weixin_33713503 2013-09-10 16:01 采纳率: 0%
浏览 237

用Express下载文件

I'm using Express and I need to download a file from server. I can easily download it with just <a href="mylink"></a>, but there is some query parameters, that I want to hide from user.

So now I'm trying to use jQuery.ajax that sending a request to Express (srv1) and then Express sending request with my parameters to the another server (srv2). Server responds me with 'Content-disposition' header and a file data. It's ok. And there is a question - can I use that file and respond with it to my initial ajax request?

The problem is, that even res.download() with files (that already on my srv1) doesn't work. Express sets headers well, but no file is prompting to download. Maybe there is a probem in ajax?

  • 写回答

1条回答 默认 最新

  • weixin_33720956 2013-09-10 16:34
    关注

    You cannot cause the browser to perform a file download with a javascript ajax request (this is a security limitation). See https://stackoverflow.com/a/9970672/266795 for details. You'll need a normal browser GET or POST request to get a proper file save dialog.

    评论

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?