const tristatetrue=-1
const file_transfer_size=16384
function transferfile(path, mimetype)
dim objfilesystem, objfile, objstream
dim char
dim sent
send=0
transferfile = true
set objfilesystem=server.createobject("scripting.filesystemobject")
set objfile = objfilesystem.getfile(path)
set objstream = objfile.openastextstream(forreading, tristatetrue)
response.addheader "content-type", mimetype
response.addheader "content-disposition","attachment;filename="&file_name
response.addheader "content-length", objfile.size
do while not objstream.atendofstream
char = objstream.read(1)
response.binarywrite(char)
sent = sent + 1
if (sent mod file_transfer_size) = 0 then
response.flush
if not response.isclientconnected then
transferfile = false
exit do
end if
end if
loop
response.flush
if not response.isclientconnected then transferfile = false
objstream.close
set objstream = nothing
set objfilesystem = nothing
end function
dim
success = transferfile(file_path, mimetype)
%>