...

View Full Version : stream text to file



Keltoi
07-13-2007, 04:21 PM
For the life of me I can't see why this isn't saving content the file:
<%
Response.ContentType = "text/csv"
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 2
objStream.Open
objStream.WriteText "this is my content"
Response.addHeader "content-disposition","attachment;filename=myfile.csv"
Response.BinaryWrite objStream.ReadText
objStream.Close
Set objStream = Nothing
%>Does anyone have any ideas?

Many thanks

Justin

Keltoi
07-16-2007, 03:20 PM
Still unsure why the above doesn't work, but have been given this solution which does:
Response.Clear
Response.ContentType = "text/csv.ms-excel"

userAgent = request.serverVariables("HTTP_USER_AGENT")
If InStr(userAgent, "MSIE") then
Response.AddHeader "Content-Disposition", "filename=" & Chr(34) & "YourFileName.csv;" & Chr(34)
Else
Response.AddHeader "Content-Disposition", "filename=YourFileName.csv;"
End if

Response.Write("my stuff here")Many thanks to anyone who took a stab at this...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum