Save file on client computer






2.07/5 (16 votes)
Feb 14, 2006

69204

963
Save file on client computer
Title: Save file on client computer
Author: Jitendra Bansiwal
Email: jkbansiwal@hotmail.com
Environmen : ASP
Introduction
This ASP page copy file from web server to client machine without zip the file.
Using the code
Copy the code and save as .asp and open in browser
Response.buffer = TRUE Response.AddHeader "content-disposition","attachment; filename=MyFile.doc" Const adTypeBinary = 1 'Create Stream object Dim BinaryStream Set BinaryStream = CreateObject("ADODB.Stream") 'Specify stream type - we want To get binary data. BinaryStream.Type = adTypeBinary 'Open the stream BinaryStream.Open 'Load the file data from disk To stream object BinaryStream.LoadFromFile "C:\Abc.doc" 'Open the stream And get binary data from the object dim BinaryData BinaryData = BinaryStream.Read Response.BinaryWrite(BinaryData) Set BinaryStream = Nothing Response.End