downloading a file

  • Thread starter Thread starter AlexB
  • Start date Start date
A

AlexB

I want to force a "save as" dialog box to open in IE when
a user downloads a text file. Here's my code:

<a href="test.log">Download File</a>

The problem is IE opens the file and shows it in the
browser. Any help is appreciated.
 
AlexB said:
I want to force a "save as" dialog box to open in IE when
a user downloads a text file. Here's my code:

<a href="test.log">Download File</a>

The problem is IE opens the file and shows it in the
browser. Any help is appreciated.

You need to make sure that when the server serves the file, it has an
appropriate disposition. Unfortunately you need to detect which kind of
browser is being used to do that properly, as some versions of IE don't
handle it appropriately.

For most browsers, use:
Content-Disposition: attachment;filename=test.log
For IE 5.5 use:
Content-Disposition: file;filename=test.log

I don't know about IE6, I'm afraid.
 
Jon provide good answer! For IE 6, you may use an ASP file instead of the
txt file like following:

<%@ Language=VBScript %>

<%Response.Buffer=true%>



<%




Response.AddHeader "Content-Type","application/download;name=hello.txt"

Response.AddHeader "Content-disposition", "attachment; filename=hello.txt"


response.write "hello"



response.end



%>


Luke

"Microsoft Security Announcement: Have you installed the patch for
Microsoft Security Bulletin MS03-026?? If not Microsoft strongly advises
you to review the information at the following link regarding Microsoft
Security Bulletin MS03-026
http://www.microsoft.com/security/security_bulletins/ms03-026.asp and/or to
visit Windows Update at http://windowsupdate.microsoft.com to install the
patch. Running the SCAN program from the Windows Update site will help to
insure you are current with all security patches, not just MS03-026."
 
Back
Top