Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automatically download created csv file 1

Status
Not open for further replies.

wbodger

Programmer
Apr 23, 2007
769
US
OK, I have a little script that creates a CSV file when somebody authenticates into a page. However, I can't figure out how to give them a link to download that file once it has been created. I am creating the same file every time somebody hits this page, but it always has to be created in real time. Thus, the file name will always be the same, though the content may be different every time due to consumer updates.

So, the question is how do I pop-up a link to the file once the file has been created?

thanks!
Willie
 
Perhaps more thoroughly, here is the code that creates the CSV file. After creation, I may need to just automatically start the file download.

Code:
'Create File System Object
Dim Fso
Set Fso = CreateObject("Scripting.FileSystemObject")

'path to folder to be written to
Dim fileName
FileName = Server.MapPath("laplinksuppression.csv")

'create the file to write to
Dim txtStream
Set txtStream = Fso.OpenTextFile(FileName, 8, True)

Do Until rs.EOF

' Write to the file
txtStream.WriteLine rs("vchEmailAddress") & ", " & rs("dtOptout")

rs.MoveNext

Loop

txtStream.Close

Thanks,
Willie
 
As soon as it's created, you can do a response.redirect to the file:

Code:
<%
...your code...
txtStream.Close
response.redirect Server.MapPath("laplinksuppression.csv")
%>

--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Duh, Thanks!! And it's not even Monday morning or Friday afternoon...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top