Joining files in asp download

E

Edgar Vigdal

Hi!

I'm trying to make a script that will download first one file (the main
file) and then download some extra data in the same stream.

1=file 1
2=file 2

111111111111111111111111111111111111+222

here is what I use today...


Server.ScriptTimeout = 900

'----- get full path of specified file
strFilename = server.MapPath(strFile)
newFilename = Request("file")
addon=Session("test")

'----- clear the buffer
Response.Buffer = True
Response.Clear

'----- create stream
Set s = Server.CreateObject("ADODB.Stream")
s.Open

'----- set as binary
s.Type = 1

'----- load in the file
on error resume next


'----- check the file exists
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>File does not exist<p>")
Response.End
end if


'----- get length of file
Set f = fso.GetFile(strFilename)
intFilelength = f.size + len(addon)


s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
Response.End
end if

'----- send the headers to the users browser
Response.AddHeader "Content-Disposition", "attachment; filename=" &
newFilename
Response.AddHeader "Content-Length", intFilelength
Response.Charset = "UTF-8"
Response.ContentType = "application/x-msdownload"

'----- output part 1 (the file) to the browser
Response.BinaryWrite s.Read
if Response.Buffer then
Response.flush
end if

'----- output part 2 (extra) to the browser
Response.BinaryWrite addon
if Response.Buffer then
Response.flush
end if

'----- tidy up
s.Close
Set s = Nothing




This is working on my Windows2000 with explorer 6, but not on my friends
winXP with explorer 6. He only gets the first part!
Anyone that can help me with this??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top