Print Page | Close Window

Downloading PDF Files

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=11514
Printed Date: 31 March 2026 at 1:35am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Downloading PDF Files
Posted By: KenW
Subject: Downloading PDF Files
Date Posted: 11 August 2004 at 4:15pm

Hi

I hope someone can help me out on my site I have several files in PDF Fomat which open ok in the Adobe Reader using the following code

pdf_files/myfile.pdf

which works fine however I would like the users to be able to download the file. Can this be done without zipping the file?

Hope someone can help

Regards

Ken



-------------
Ken Home User enjoys ASP as a hobby



Replies:
Posted By: dpyers
Date Posted: 11 August 2004 at 4:40pm

How a browser handles a file type is entirely up to the end user. Some opt to automatically open it, some to automatically save it, and some to be presented a prompt asking what to do. This applies to all file types - pdf's, zips, whatever.

On my PC, I have eveything set up to ask for a prompt for every file type. Apparently on your PC, you have pdf's set up to automatically open. Don't assume that every user wants to handle a file the way you prefer.

The best you can so is to ask the user to right-click on a file link and select "save as" from the pop-up menu.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: dpyers
Date Posted: 12 August 2004 at 12:14pm

After I posted the above, found this piece of code in a news group. Haven't tried it, and I think ADO has a limit of something like 2Mb, but it's worth a shot. Basically, it changes the http header going to the client.

Response.ContentType = "application/asp-unknown" ' arbitrary
Response.AddHeader "content-disposition","attachment; filename=" & theFile
Set adoStream = Server.CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(thePath)
Response.BinaryWrite adoStream.Read()
adoStream.Close
Set adoStream = Nothing
Response.End



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: KenW
Date Posted: 12 August 2004 at 12:25pm

Thanks DP I will try it out

Regards

Ken



-------------
Ken Home User enjoys ASP as a hobby


Posted By: Bluefrog
Date Posted: 17 August 2004 at 9:15am
There might be another way to do that - try Googling for "force download asp". I've read a few things about it, but never needed it.

-------------
http://renegademinds.com/" rel="nofollow - Renegade Minds - Guitar Software http://renegademinds.com/Default.aspx?tabid=65" rel="nofollow - Slow Down Music


Posted By: Semikolon
Date Posted: 17 August 2004 at 1:15pm
I have tried to find a solution to this, and the only thing I came up with was using ADODB.Stream.. but it was good enough for me.. don't think there's a limit on 2MB though..



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net