If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ASP - cant download txt file

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-20-03, 07:58
BScullio BScullio is offline
Registered User
 
Join Date: Aug 2003
Posts: 2
Question ASP - cant download txt file

I have a problem. I've prepared a delimited text file of data, and want the user to be able to download it to the local machine. This is how I have done it, but it seems to open the file for viewing rather than download it:

Click <a href='Myfile.txt'>here</a> to download.


Help!
Reply With Quote
  #2 (permalink)  
Old 08-20-03, 08:33
unatratnag unatratnag is offline
Registered User
 
Join Date: Jul 2003
Location: Ohio/Chicago
Posts: 75
uh oh, did you click do not remind me again button at one time so it doesn't prompt ever?

did you try it on a different machine besides yours?

Did you set up the server to interpret .txt files?
Reply With Quote
  #3 (permalink)  
Old 08-20-03, 09:28
BScullio BScullio is offline
Registered User
 
Join Date: Aug 2003
Posts: 2
Im not sure If I clicked dont prompt ever. I may have. Which means that others probably would have too. Which makes this solution unsuitable.

I have just tried it on 2 other machines with the same result.

Im researching setting the server to interpret .txt files.


Do you (or anybody) know of a better way to do it?
Reply With Quote
  #4 (permalink)  
Old 08-20-03, 19:02
Seppuku Seppuku is offline
Useless...
 
Join Date: Jul 2003
Location: SoCal
Posts: 721
Quote:
Originally posted by BScullio
Im not sure If I clicked dont prompt ever. I may have. Which means that others probably would have too. Which makes this solution unsuitable.

I have just tried it on 2 other machines with the same result.

Im researching setting the server to interpret .txt files.


Do you (or anybody) know of a better way to do it?
I'm assuming, since this is the ASP forum, that you can execute ASP code. The best way to FORCE them to download the file is to stream it to them through ASP:

Code:
<%
Response.Buffer = True
Response.Clear

Dim strFilePath, strFileName

Const adTypeBinary = 1

Set objStream = Server.CreateObject("ADODB.Stream")

strFilePath = Server.MapPath("/virtualpath/tofolder") & "\"
strFileName = "mytextfile.txt"

objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath & strFileName

Response.AddHeader "Content-Disposition", "attachment; filename=" & StrFileName
Response.Charset = "UTF-8"
Response.ContentType = "text/plain"
'Google "Mime Types" for addtional Content Type definitions

Response.BinaryWrite objStream.Read
Response.Flush

objStream.Close
Set objStream = Nothing

%>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On