How to prompt a user to download a text file

  • Thread starter Thread starter Abhishek Srivastava
  • Start date Start date
A

Abhishek Srivastava

Hello All,

I am developting an application where we generate a text file. Now we
display the page with links to the text file.

If the user clicks on the link the browser displays the contents of the
text file.

I don't want this behaviour. I want the browser to prompt that does the
user want to open or save the file. if the user clicks open then the
contents of the file are displayed. else the text file is saved.

How can I get this kind of behavious.... can I set anything in my http
header which forces IE to change its behaviour of directly displaying
the text file?

regards,
Abhishek.
 
Abhishek,

Enable the "confirm open after download" option for that filetype (Txt):

Click "Start" -> "Program Files" -> "Windows Explorer".

Then click "Tools" -> "Folder Options".

Change to the "File Type" tabs.

Scroll down to locate the file type. Highlight the filetype "txt" and click
the "Advanced" button.

Then check the option "confirm open after download".

--
Regards,
Ramesh
(e-mail address removed)


Hello All,

I am developting an application where we generate a text file. Now we
display the page with links to the text file.

If the user clicks on the link the browser displays the contents of the
text file.

I don't want this behaviour. I want the browser to prompt that does the
user want to open or save the file. if the user clicks open then the
contents of the file are displayed. else the text file is saved.

How can I get this kind of behavious.... can I set anything in my http
header which forces IE to change its behaviour of directly displaying
the text file?

regards,
Abhishek.
 
Ramesh,

Thank you so much for your reply.

Can I accomplish this by chaning something in the http header?

since I am writing the text data on the http response object, I don't
have control over the settings of the users browser.

I will have to do something to the http header and response to get the
desired effect.

Of course, my last resort would be to put a readme.txt file on my
website asking all users to change their windows explorer settings.

regards,
Abhishek.
 
Abhishek Srivastava said:
Hello All,

I am developting an application where we generate a text file. Now we
display the page with links to the text file.

If the user clicks on the link the browser displays the contents of the
text file.
How can I get this kind of behavious.... can I set anything in my http
header which forces IE to change its behaviour of directly displaying
the text file?

Yes, investigate the following headers:
Mime-type: application/x-msdownload
Content-type: application/octet-stream
Content-Disposition: attachment

Also see http://www.faqts.com/knowledge_base/view.phtml/aid/141/fid/59
 
Back
Top