Force download problems

Results 1 to 2 of 2

Thread: Force download problems

  1. #1
    Join Date
    Dec 1969

    Default Force download problems

    Hi all,<BR><BR>Question: I am trying to create a text file on one page and then redirect the user to another where they are prompted to download this file with the save/open dialog box.<BR><BR>However, the page that is meant to download the file comes up blank and doesnt prompt me to download. here is the code:<BR><BR>&#060;!--#include file="../include/General/"--&#062;<BR>&#060;%<BR>Dim intReportID<BR>Dim strTextFileName<BR><BR>intReportID = CInt(Request.QueryString("report_id") )<BR><BR><BR><BR> <BR>strTextFileName = "E:Inetpubwwwrootmysitepress_reports\" & intReportID & "\" & intReportID & ".txt"<BR><BR>Dim objStream<BR>Set objStream = Server.CreateObject("ADODB.Stream")<BR><BR>Respons e.AddHeader "Content-Disposition", "attachment; filename =" & strTextFileName<BR>Response.AddHeader "Content-Length", strTextFileName<BR>objStream.Open<BR>objStream.Loa dFromFile(strTextFileName)<BR>Contents = objStream.ReadText<BR>Response.BinaryWrite Contents<BR><BR><BR>objStream.Close<BR>Set objStream = nothing<BR>%&#062;<BR><BR>Any ideas as to why it isn&#039;t working.<BR><BR>Thanks,<BR>Ross

  2. #2
    Join Date
    Dec 1969

    Default Something funny there...

    How come you use ReadText and then use BinaryWrite????<BR><BR>Seems like a mismatch, to me.<BR><BR>Either ReadBinary/Response.BinaryWrite<BR>or ReadText/Response.Write<BR><BR>HEY! ANOTHER BIG GOOF!<BR><BR> Response.AddHeader "Content-Length", strTextFileName<BR><BR>WHAT???? strTextFileName isn&#039;t a *NUMBER*! How can you use *THAT* as the content length????<BR><BR>Leave out that line of get a *REAL* content length.<BR><BR>

Posting Permissions

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