http下载文件名 [英] http download file name
问题描述
我是否知道如何为a-href文件下载分配文件名。
May i know how to assign a file-name to a a-href file download.
<a href="http://localhost:8080/couch/getFile?dbName=xxx&file=test.xml">get-file</a>
右键单击并另存为:在后台运行的服务将返回test.xml内容和用户可以在本地保存。但每次用户都需要输入文件名进行保存。相反,我正在考虑拉取test.xml。我是否知道如何告诉浏览器使用test.xml作为下载文件名?
On right-clicking and Save as: A services running on the background will return test.xml contents and the user can save it locally. But here everytime user needs to type a filename for saving. Instead i'm thinking to pull the test.xml. May i know how to tell the browser to use "test.xml" as a download file name?
HTTP响应上的设置标头是否有效?如果可以,我可以知道我们怎么做?
Will setting headers on HTTP response would work? if so may i know how we can do that?
提前致谢!
Shiv
Thanks in advance! Shiv
推荐答案
您需要附加HTTP响应标题Content-Disposition
You need to append the HTTP response header "Content-Disposition"
Response.AppendHeader("content-disposition", "attachment; filename=\"" + fileName +"\"");
干杯。
这篇关于http下载文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!