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

File Download

Status
Not open for further replies.

LaneyVC50

Technical User
Mar 1, 2002
17
GB
I am looking for a way of invoking the "File Download/Save As" window when a visitor to my site clicks on a link, so that they can download it, rather than have the file open in it's native program.

At the moment, I either have to tell people to "right click and save as" or post the file as a zip file.


Any ideas would be greatly appreciated
 
You can use:

<a href=&quot;file.txt&quot; onClick=&quot;javascript:document.execCommand ('SaveAs',1,'document.doc'); return
true;&quot;>Save File</a>

Or with a server-side header:

&quot;content-disposition&quot;,&quot;attachment; filename=document.doc&quot; Regards
David Byng
spider.gif

davidbyng@hotmail.com
 
There might be a way, if you have access to IIS.

Save the files you want to download in a new directory, for which you add a new HTTP header (IIS - Properties), like this:

Header-Name: Content-Disposition
Header-Value: attachment

Now, the links to the files should open the &quot;File Download/Save As&quot; window when you click them, instead of openning the files.

This works for me in most of the cases, but I think there might be a bug in IE, sometimes it opens the files. The Microsoft site might have more info about this.



vlad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top