Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Download CSV / Save As filename


Message #1 by "Chris Chaffee" <chris@u...> on Fri, 23 Mar 2001 12:20:00 -0800
I've got a page that generates a CSV and sends it to the browser, which

I need to save to a file.  I've tried tweaking the headers, and I can

make the browser prompt to save the file, but I can't figure out how to

specify the filename.  It defaults to the name of the page (csvout.asp)

which is not what I want the file to be called.  Do I need to add a

header that specifies the filename, and if so what is it?  Here's part

of the code:



	Response.Clear

	Response.ContentType =3D "application/octet-stream"

	Response.AddHeader "Accept-Ranges", "bytes"

	Response.Flush

	while not rsSymbolFind.EOF

		Response.Write(rsSymbolFind.Fields(0) & "," &

rsSymbolFind.Fields(1) & vbCrLf)

		rsSymbolFind.MoveNext

	wend

	Response.End



I got the current header values by making an HTTP request for a real CSV

file through a telnet client and looking at what headers the server

returned, so I think that part is pretty accurate.  I just need to get

the filename in there somewhere.



Thanks,



Chris Chaffee

Technology Engineer

UNX, Inc.

Member NASD/SIPC

175 E. Olive Ave., 2nd Fl.

Burbank, CA 91502

(xxx) xxx-xxxx  x317

chris@u...

Message #2 by Imar Spaanjaars <Imar@S...> on Sat, 24 Mar 2001 11:21:33 +0100
You can try to add the following header:



sFileName = "blablabla.csv"

Response.AddHeader "Content-Disposition", "filename=" & sFileName





Hope this helps,



Imar





At 12:20 PM 3/23/2001 -0800, you wrote:

>I've got a page that generates a CSV and sends it to the browser, which

>I need to save to a file.  I've tried tweaking the headers, and I can

>make the browser prompt to save the file, but I can't figure out how to

>specify the filename.  It defaults to the name of the page (csvout.asp)

>which is not what I want the file to be called.  Do I need to add a

>header that specifies the filename, and if so what is it?  Here's part

>of the code:

>

>         Response.Clear

>         Response.ContentType = "application/octet-stream"

>         Response.AddHeader "Accept-Ranges", "bytes"

>         Response.Flush

>         while not rsSymbolFind.EOF

>                 Response.Write(rsSymbolFind.Fields(0) & "," &

>rsSymbolFind.Fields(1) & vbCrLf)

>                 rsSymbolFind.MoveNext

>         wend

>         Response.End

>

>I got the current header values by making an HTTP request for a real CSV

>file through a telnet client and looking at what headers the server

>returned, so I think that part is pretty accurate.  I just need to get

>the filename in there somewhere.

>

>Thanks,

>

>Chris Chaffee




  Return to Index