Web Design and Development Forums

Text file download

This is a discussion on "Text file download" within the ASP Forum section. This forum, and the thread "Text file download are both part of the Program Your Website category.

Old Dec 5th, 2005, 16:56   #1 (permalink)
New Member
 
Join Date: Dec 2005
Posts: 2
Text file download

Hallo, i'm a novice. I have, on mi website, a text file. I want to permit the download of it.
If i use this code:
<a href="filemane.txt"><b> Download</b></a>it will be displayed on the screen but not donloaded.
Could someone hel me?
Thanks in advance.
Herlekin
harlekin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Dec 5th, 2005, 18:08   #2 (permalink)
Rob
Head Admin & CEO
 
Rob's Avatar
 
Join Date: Jul 2003
Location: bug busting new style
Age: 34
Posts: 3,311
Blog Entries: 7
Send a message via MSN to Rob Send a message via Skype™ to Rob
Re: Text file download

There are ways round this. You can either direct people to right click and 'save target as', or you can 'Stream' the file to the browser:-

HTML: Select all
<%
'--------------------------------------------
Response.Buffer = True
Dim strFilePath, strFileSize, strFileName
Const adTypeBinary = 1
strFilePath = "C:\whatever\folder\"
strFileSize = xxx (optional)
strFileName = the file name 
Response.Clear
'8*******************************8
' Requires MDAC 2.5 to be stable
' I recommend MDAC 2.6 or 2.7
'8*******************************8
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath
strFileType = lcase(Right(strFileName, 4))
' Feel Free to Add Your Own Content-Types Here
Select Case strFileType
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".zip"
ContentType = "application/zip"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".asp"
ContentType = "text/asp"
Case Else
'Handle All Other Files
ContentType = "application/octet-stream"
End Select
 
Response.AddHeader "Content-Disposition", "attachment; filename= strFileName
Response.AddHeader "Content-Length", strFileSize
' In a Perfect World, Your Client would also have UTF-8 as the default 
' In Their Browser
Response.Charset = "UTF-8"
Response.ContentType = ContentType
Response.BinaryWrite objStream.Read
Response.Flush
objStream.Close
Set objStream = Nothing
%>
__________________
Rob Collyer - SEO Specialist (8 years+)
Owner & Founder of Webforumz.com

My Mrs's site:- Student Midwife Forums

I am currently unavailable for private work
-------------------------------------------------

Last edited by Rob; Dec 5th, 2005 at 18:12.
Rob is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old Dec 5th, 2005, 18:23   #3 (permalink)
New Member
 
Join Date: Dec 2005
Posts: 2
Re: Text file download

Taky you, i will tray this way
harlekin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
text, file, download

Thread Tools
Rate This Thread
Rate This Thread:

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow users to download flv file @lun Flash & Multimedia Forum 4 Jan 29th, 2008 17:33
Download button - to download a PDF file attila001122 HTML Forum 3 Dec 9th, 2007 16:09
file download help acrikey HTML Forum 7 Aug 23rd, 2007 00:11
PHP file download script sabatier PHP Forum 2 Aug 14th, 2007 11:43
File Download nileshnaik JavaScript Forum 1 Nov 27th, 2006 16:13



Latest Updates

All Points SEO Security Advisory - CHECK YOUR SITE NOW!

Creative Coding :: February 2008

Webforumz is sponsored by: WESH UK Web Hosting
All times are GMT. The time now is 09:17.

Sleep Study Scoring :: Free Bet :: Website Templates :: Online Betting :: Bookmakers :: Funny Quotes :: Internet Recruitment Software :: Microsoft CRM Experts :: Online Casino :: Decorated Christmas Trees :: Midwife Forums :: Football Betting :: Ecommerce Software :: Web Hosting :: Football Stats :: Dry Cleaning Collection :: xtreme wales - extreme clothing :: Apuestas :: Sharepoint Consultants :: Website Optimisation :: Office Clearance London :: Sharepoint Experts :: Sports Betting :: Casino :: Website Templates :: Web Design Development India :: Online Gambling

Powered by: vBulletin Version 3.7, Copyright ©2000 - 2008, Jelsoft Enterprises Limited.
© 2003-2008 Webforumz.com : All Rights Reserved
Search Engine Friendly URLs by vBSEO 3.2.0 RC6


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59