I'm using Response.BinaryWrite to display some files that are outside of my webfolder and do not have Read permissions with IIS.
My question is about the code below. When I open or save files using this code the files are always named BinDoc.asp which is the name of this file.
Is there a way I can specify the name of the file?
BinDoc.asp
My question is about the code below. When I open or save files using this code the files are always named BinDoc.asp which is the name of this file.
Is there a way I can specify the name of the file?
BinDoc.asp
Code:
Response.buffer = TRUE
Dim vntStream
Dim oMyObject
Dim FileName
Dim StoreFolder
FileName = Request.QueryString("FileName")
StoreFolder = Request.QueryString("StoreFolder")
Dim CaseFileType
CaseFileType = UCASE(Right(Request.QueryString("FileName"),3))
Select Case CaseFileType
Case "PDF" 'Adobe PDF
Response.ContentType = "application/pdf"
Case "DOC" 'Microsoft Word
Response.ContentType = "application/msword"
Case "XLS" 'Microsoft Excel
Response.ContentType = "application/vnd.ms-excel"
Case "PPT" 'Microsoft PowerPoint
Response.ContentType = "application/ms-powerpoint"
Case "GIF" 'GIF Image
Response.ContentType = "image/gif"
Case "JPG" 'JPEG Image
Response.ContentType = "image/jpeg"
End Select
Set oMyObject = Server.CreateObject("ASPBinFile.clsASPBinFile")
vntStream = oMyObject.readBinFile("c:\datastore\documents\"& StoreFolder &"\"& FileName)
Response.BinaryWrite(vntStream)
Set oMyObject = Nothing
Response.End