Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Lincoln (UK)
    Posts
    138
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Unhappy stream text to file

    For the life of me I can't see why this isn't saving content the file:
    Code:
    <%
    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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Lincoln (UK)
    Posts
    138
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Still unsure why the above doesn't work, but have been given this solution which does:
    Code:
    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...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •