By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,727 Members | 1,422 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,727 IT Pros & Developers. It's quick & easy.

Allow download of a "virtual" file

P: n/a
Hello !

I am having a problem which I thought was an easy one but which starts
to drive me crazy.

Imagine that I have a text displayed in a div. I would like a button
to download a text file containing this text (no formatting, just
text).

How should I do that ?
Can I somehow build a file in javascript and then propose to the user
to save it ? (the normal "save or open with" dialog)

Or am I forced to have a temporary file on the server to link to ? and
then wouldn't the browser simply display this txt file instead of
proposing to save it ?

Any help would be welcomed !
Thanks in advance

Barth
Nov 21 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Wed, 21 Nov 2007 09:33:22 -0800 (PST), ba*******************@gmail.com
wrote:
[downloading text using JavaScript]
Or am I forced to have a temporary file on the server to link to ?

I would imagine so.

and then wouldn't the browser simply display this txt file instead of
proposing to save it ?

If you send it with an HTTP header such as the following:

Content-disposition: attachment; filename=something.txt

....then most browsers will bring up a requester to save the file, with the
specified name as a default.
--
Safalra (Stephen Morley)

Sortable Tables In javascript:
http://www.safalra.com/web-design/ja...rtable-tables/
Nov 21 '07 #2

P: n/a
Thank you for your help !

Barth
Nov 22 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.