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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file downloading

Status
Not open for further replies.

JazzLeg

Programmer
Aug 22, 2002
63
GB
hi
I have a page where i've used href="file//etc... for several different documents.

When a user clicks this link I would like the file to be downloaded to the users computer using the normal save as dialog box.

But, when the files are text files it just opens these files in another explorer window. Is there away to avoid this so that the users can only download these files?

Many thanks

 
You can use:

Code:
<a href=&quot;file.txt&quot; onClick=&quot;javascript:document.execCommand ('SaveAs',1,'file.txt'); return
true;&quot;>Save File</a>
Regards
David Byng
spider.gif

davidbyng@hotmail.com
 
Or with ASP header:

download.asp?dFile=file.txt

Code:
<%

Response.Buffer = True

Dim dFile

dFile = Request(&quot;dFile&quot;)

Response.AddHeader(&quot;content-disposition&quot;,&quot;attachment; filename=&quot; & dFile)

%>
Regards
David Byng
spider.gif

davidbyng@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top