Hey Everyone,
I've built an online ticketing system, where users need to log in, and can upload files.
In order to not allow anybody not logged in to use a direct link to the files, I have an asp page, that checks for an active session, and on demand, it streams the requested file in binary.
It works fine for *.doc and *.xls But I'm having issues with *.pdf and *.txt
*.txt gives me a blank page. (but in view source, it shows up) How can this just prompt for a download screen?
*.pdf gives me an error pop-up:
Internet Explorer cannot download...filedownload.asp?FileNumber=1 from server.domain.com
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
I've tried about 50 times, and it consistantly refuses to download the pdf file.
With a direct link the file downloads fine.. so I know the file is okay.
The same exact script downloads the word doc and excel files fine, so I know the directories are not misspelled.
I've double checked the file name too.. but still gives me the error.
Any ideas?
I've built an online ticketing system, where users need to log in, and can upload files.
In order to not allow anybody not logged in to use a direct link to the files, I have an asp page, that checks for an active session, and on demand, it streams the requested file in binary.
It works fine for *.doc and *.xls But I'm having issues with *.pdf and *.txt
*.txt gives me a blank page. (but in view source, it shows up) How can this just prompt for a download screen?
*.pdf gives me an error pop-up:
Internet Explorer cannot download...filedownload.asp?FileNumber=1 from server.domain.com
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
I've tried about 50 times, and it consistantly refuses to download the pdf file.
With a direct link the file downloads fine.. so I know the file is okay.
The same exact script downloads the word doc and excel files fine, so I know the directories are not misspelled.
I've double checked the file name too.. but still gives me the error.
Code:
<%@ Language=VBScript %>
<!-- #include virtual="/inc/adovbs.asp" -->
<%
FileNumber = Request("FileNumber")
select case FileNumber
case "1"
FileNameSent = "file1.pdf"
case "2"
FileNameSent = "file2.xls"
case "3"
FileNameSent = "file3.txt"
case "4"
FileNameSent = "file4.doc"
end select
if FileNameSent <> "" then
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile "c:\downloads\" & FileNameSent
response.buffer=true
FileNameResponse = "filename=" & FileNameSent & ";"
response.addheader "Content-Disposition", FileNameResponse
response.ContentType = "application/octetstream"
response.binarywrite objStream.Read
objStream.Close
set objStream = nothing
end if
%>
Any ideas?