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
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