neeraj523
asked on
prevent browser to open text and pdf files..
Hello
I want to know if there is a way to force web browsers to open download text and pdf documents intsead of opening it there only..
Basically, i want my web users to download pdf and text files intead opening it in the borwser irrespective of their local browser settings.. Is there a way to force browser in this way programatically ??
Thank You
Neeraj
I want to know if there is a way to force web browsers to open download text and pdf documents intsead of opening it there only..
Basically, i want my web users to download pdf and text files intead opening it in the borwser irrespective of their local browser settings.. Is there a way to force browser in this way programatically ??
Thank You
Neeraj
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello darkeryu
I have tried solution given by u.. but not got working fine.. It is opening the download window but gives error that specific server is not not found..
Neeraj
I have tried solution given by u.. but not got working fine.. It is opening the download window but gives error that specific server is not not found..
Neeraj
<%
Function ReadBinaryFile(FileName)
Const adTypeBinary = 1
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream ")
BinaryStream.Type = adTypeBinary
BinaryStream.Open
BinaryStream.LoadFromFile FileName
ReadBinaryFile = BinaryStream.read
end function
Dim fso, f1, Arq, Nome, Ext
Arq = Server.MapPath("test.txt") 'here u specify the location of the file
Set fso = CreateObject("Scripting.Fi leSystemOb ject")
Set f1 = fso.GetFile(Arq)
Nome = fso.GetFileName(Arq)
Ext = fso.GetExtensionName(Arq)
Response.Clear()
Response.ContentType = "application/"&Ext
response.AddHeader "Content-Disposition", "attachment; filename="&Nome&""
response.BinaryWrite(ReadB inaryFile( Arq))
Response.Flush()
%>
Function ReadBinaryFile(FileName)
Const adTypeBinary = 1
Dim BinaryStream
Set BinaryStream = CreateObject("ADODB.Stream
BinaryStream.Type = adTypeBinary
BinaryStream.Open
BinaryStream.LoadFromFile FileName
ReadBinaryFile = BinaryStream.read
end function
Dim fso, f1, Arq, Nome, Ext
Arq = Server.MapPath("test.txt")
Set fso = CreateObject("Scripting.Fi
Set f1 = fso.GetFile(Arq)
Nome = fso.GetFileName(Arq)
Ext = fso.GetExtensionName(Arq)
Response.Clear()
Response.ContentType = "application/"&Ext
response.AddHeader "Content-Disposition", "attachment; filename="&Nome&""
response.BinaryWrite(ReadB
Response.Flush()
%>
I've seen this question asked many a time and this is the only thread i have seen with a reasonable response:
https://www.experts-exchange.com/questions/20811501/download-not-open-pdf-files.html
Apresto