This topic has been archived. It cannot be replied.
-
工作学习 / IT技术讨论 / I have a txt file,if I open it in browser,I don't want to see the file opened in browser directly,I need a dialog ask to save or open the file,how can I do it?
-cathy618(cathy);
2003-8-7
(#1321687@0)
-
add <%Response.AddHeader "content-disposition","attachment; filename=temp.txt" %> in your asp file
-angela01(An);
2003-8-7
(#1321741@0)
-
thank you,where should I add this,in my txt file?what's relationship between your asp and my txt?
-cathy618(cathy);
2003-8-7
(#1321767@0)
-
you put a hyperlink in 1.htm ,this hyperlink redict to 2.asp ,and add <%Response.AddHeader "content-disposition","attachment; filename=temp.txt" %> in 2.asp,when you click the link in 1.htm,it'll show an open/save dialog
-angela01(An);
2003-8-7
{64}
(#1321792@0)
-
Thank you.this worked only if I copy all of content of my txt file in to 2.asp.but if I have some other file instead of txt,like .pdf,how can I download them without open them?
-cathy618(cathy);
2003-8-7
(#1321852@0)
-
1.asp & 2.asp1.asp:
<html>
<head>
<title></title>
</head>
<body>
<a href="http://localhost/2.asp?fn=temp.txt">Download temp.txt</a>
<a href="http://localhost/2.asp?fn=HowTo.pdf">Download HowTo.pdf</a>
</body>
</html>
2.asp:
<html>
<head>
<title></title>
</head>
<body>
<%
fn = Request.QueryString("fn")
Response.AddHeader "content-disposition","attachment; filename=" & fn %>
</body>
</html>
-angela01(An);
2003-8-7
{418}
(#1321904@0)
-
in this way,if you click download howto.pdf,a dialog pops up and ask you to save as howto.pdf.click YES,you can get howto.pdf,but you can't open if use acrobat,if you open it use notepad,you will see the content is 2.asp,
by summary,filename only control the file's name,but not the file you need tobe download.the doloaded file is 2.asp itself???
-cathy618(cathy);
2003-8-7
{246}
(#1321916@0)
-
yeah,that's the problem.I'm doing some research on it .Got no luck so far.
.Net can do that easily.
-angela01(An);
2003-8-8
(#1323813@0)