Streaming Word-Document Problems

P

Philipp Lenssen

I have a password-protected website with downloads. The
password-protection needed its own login-screen, so I use a
session-object. It works well but now I also want the downloads (PDFs
and Word-Documents) to check if the user is logged-in. When I stream
PDFs, all works well. When I stream DOCs, the Word-File seems broken
when I open it -- a lot of strange characters, some authors
information, and so on.

Can anybody help me?

This is my code ("stmPic" is just a left-over from an online sample...):

response.clear
if inStr(sPath, ".pdf") >= 1 then
Response.ContentType = "application/pdf"
elseif inStr(sPath, ".doc") >= 1 then
Response.ContentType = "application/msword"
Response.AddHeader "content-disposition", _
"attachment; filename=download.doc"
else ' just a fall-back...
Response.ContentType = "application/x"
end if

set stmPic = Server.CreateObject("ADODB.Stream")

stmPic.Open
stmPic.LoadFromFile sPath
stmPic.Type = 1

Response.BinaryWrite stmPic.Read
Response.Flush

stmPic.Close
 

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,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top