Skip to content

Instantly share code, notes, and snippets.

@dflima
Created November 12, 2012 19:21
Show Gist options
  • Save dflima/4061297 to your computer and use it in GitHub Desktop.
Save dflima/4061297 to your computer and use it in GitHub Desktop.
Simple download script with asp
<%
On Error Resume Next
downloadPath = <<path>>
fileName = <<name>>
fileExt = <<extension>>
varTo = Server.MapPath(downloadPath) & "\" & fileName & fileExt
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile varTo
If Err = 0 Then
Response.AddHeader "Content-Disposition", "attachment; filename=" & fileName & fileExt
Response.Charset = "UTF-8"
Response.ContentType = "application/vnd.ms-excel" 'Download Excel Files
Response.BinaryWrite objStream.Read
End If
objStream.Close
Set objStream = Nothing
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment