<% ' 發展單位:風禹科技驗證有限公司 ' 撰寫人:鄭子璉(Tzu-Lien, Cheng, 璉璉) ,成大水利博肄,微軟最有價值專家 ' Web: http://tlcheng.twbbs.org/TLCheng/ E-Mail: qvb3377@ms5.hinet.net ' -------------------------------------------------------------------------------------- Expires = -1 ResponseBuffer = True Private Function ResponseInit() With Response .Expires = Expires .Buffer = ResponseBuffer .Clear End With End Function Private Function ResponseFinal() With Response .Flush .Clear .End End With End Function Public Function SetResponseHeader(Byval sContentType, Byval sFileName, Byval bSaveFile) Dim sContentDisposition With Response If bSaveFile Then sContentDisposition = "attachment; " ' 強制存檔,未設定則依瀏覽器預設開啟或存檔 End If If Len(sFileName) > 0 Then sContentDisposition = sContentDisposition & "filename=" & sFileName ' 檔名 End If If Len(sContentDisposition) > 0 Then .AddHeader "Content-disposition", sContentDisposition End If .ContentType = sContentType End With End Function Public Function ResponseFile(Byval vOutput, Byval sContentType, Byval sFileName, Byval bSaveFile) ResponseInit SetResponseHeader sContentType, sFileName, bSaveFile Select Case VarType(vOutput) Case vbString Response.Write vOutput Case Else Response.BinaryWrite vOutput End Select ResponseFinal End Function Public Function ResponseTextFile(Byval OutputFile, Byval sContentType, Byval sFileName, Byval bSaveFile) ResponseInit SetResponseHeader sContentType, sFileName, bSaveFile Response.Write OutputFile ResponseFinal End Function Public Function ResponseBinaryFile(Byval BinaryFile, Byval sContentType, Byval sFileName, Byval bSaveFile) ResponseInit SetResponseHeader sContentType, sFileName, bSaveFile Response.BinaryWrite BinaryFile ResponseFinal End Function %>