Download Sometimes you want a user to download a binary file instead of opening it inside the browser window.
There are several different ways to accomplish this.
Generically:
<%
FileName = "Document.doc"
Response.ContentType = "Application/octet-stream"
Response.AddHeader "Content-disposition", "attachment"; filename = "& filename
Set Stream = Server.CreateObject ("ADODB.") Stream ")
Stream.open
Stream.loadfromfile Server.MapPath (Filename)
Conents = Stream.readtext
Response.BinaryWrite Contents
Stream.Close
Set Stream = Nothing
%>
If you know the ' file type ' you would like the user to download, try:
<%
Filename = "Document.doc"
Response.ContentType = "Application/vnd.ms-word"
Response.AddHeader "Content-disposition", "attachment"; Filename= "& filename
%>
Other Content Types:
Vnd.ms-excel-for Excel
Vnd.ms-powerpoint-for PowerPoint
Vnd.ms-project-for Microsoft Project
Pdf-for Adobe Acrobat Documents
Rtf-for Rick Text Documents
Vnd.lotus-wordpro-for WordPro
Vnd.lotus-1-2-3-for Lotus 1-2-3
Vnd.visio-for Visio
Jpeg-for JPG Image File
Gif-for GIF Image File
Png-for PNG Image File
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service