zombeen
asked on
download , not open pdf files
Dear experts.
I hv a problem with pdf files. In my site there are a number of links for pdf files. If you left click the pdf file, it tries to open in the browser only. I've heard through Content-disposition you can force IE/NN to force download the file rather than open. Can anyone throw more light on how to do this
Thks in advance
I hv a problem with pdf files. In my site there are a number of links for pdf files. If you left click the pdf file, it tries to open in the browser only. I've heard through Content-disposition you can force IE/NN to force download the file rather than open. Can anyone throw more light on how to do this
Thks in advance
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thks u all for the comments. Hongjun's and webmonkey's comments seem the most valuale coz o their simplicity. Nothing taking away from Fritz though.
I had one question though. The asp page will have many links for pdf files on the pags and all of them dynamic (searched using combination of FSO & ADO)... How then will I change my Response.Header line...Where shd it be placed?
Thks
Zombeen
I had one question though. The asp page will have many links for pdf files on the pags and all of them dynamic (searched using combination of FSO & ADO)... How then will I change my Response.Header line...Where shd it be placed?
Thks
Zombeen
ASKER
Thks all for your comments. I wld like to go for the simpler options given by hongjun and webmonkey..nothing taking away from Frtiz' reposnse though. That might well be the option I hv to choose.
My situation is that i have multiple links for pdf files in my asp page, all called dynamically thru FSO & ADO. How will I tackle this in the statement you have provided below , and where shd it be placed (in the head section?)
Thks
Zombeen
My situation is that i have multiple links for pdf files in my asp page, all called dynamically thru FSO & ADO. How will I tackle this in the statement you have provided below , and where shd it be placed (in the head section?)
Thks
Zombeen
ASKER
Thks all for your comments. I wld like to go for the simpler options given by hongjun and webmonkey..nothing taking away from Frtiz' reposnse though. That might well be the option I hv to choose.
My situation is that i have multiple links for pdf files in my asp page, all called dynamically thru FSO & ADO. How will I tackle this in the statement you have provided below , and where shd it be placed (in the head section?)
Thks
Zombeen
My situation is that i have multiple links for pdf files in my asp page, all called dynamically thru FSO & ADO. How will I tackle this in the statement you have provided below , and where shd it be placed (in the head section?)
Thks
Zombeen
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
vijay7248's approach will work. Pass filename as querystring and set filename of Response.AddHeader using the passed in querystring.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thks a ton for so many comments... and sorry for late response.. i m going to check some of these today/tom, and get back here, hopefully with my problem solved
Here's a sub that will download a file just call it with teh filename,pathname
This was taken from another post and edited by me as I had the same question recently.
Private Sub DownlaodFile(File, PathName)
Dim objFSO
Set objFSO = Server.CreateObject("Scrip ting.FileS ystemObjec t")
Response.Clear
Response.Buffer = true
If objFSO.FileExists(PathName ) Then
Response.AddHeader "Content-Type", "application/file-download "
Response.AddHeader "Content-Disposition", "attachment; filename=" & File
Dim objStream
Set objStream = Server.CreateObject("ADODB .Stream")
objStream.Open
objStream.Type = 1
Response.CharSet = "UTF-8"
objStream.LoadFromFile(Pat hName)
Response.BinaryWrite(objSt ream.Read)
objStream.Close
Set objStream = Nothing
Else
Response.Write("No such file exists.")
End If
Set objFSO = Nothing
End sub %>
This was taken from another post and edited by me as I had the same question recently.
Private Sub DownlaodFile(File, PathName)
Dim objFSO
Set objFSO = Server.CreateObject("Scrip
Response.Clear
Response.Buffer = true
If objFSO.FileExists(PathName
Response.AddHeader "Content-Type", "application/file-download
Response.AddHeader "Content-Disposition", "attachment; filename=" & File
Dim objStream
Set objStream = Server.CreateObject("ADODB
objStream.Open
objStream.Type = 1
Response.CharSet = "UTF-8"
objStream.LoadFromFile(Pat
Response.BinaryWrite(objSt
objStream.Close
Set objStream = Nothing
Else
Response.Write("No such file exists.")
End If
Set objFSO = Nothing
End sub %>
Which is a variation of what I posted above, no?
Fritz the Blank
Fritz the Blank
zombeen, good luck
ASKER
thks to all!. they were all wonderful solutions in their own right
sorry if i hv missed alotting points to anyone
Zombeen
sorry if i hv missed alotting points to anyone
Zombeen
You're welcome and good luck with the project.
Fritz the Blank
Fritz the Blank
Thanks for accepting my answer zombeen
Good luck!
-Vijay
Good luck!
-Vijay
hongjun's answer might work. But just in case it doesn't, try this instead...
<%
Response.AddHeader "content-disposition","att
ContentType = "bad/type"
%>
HOPE THIS HELPS!
Webmonkey