473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to force download?

Hello,

in my web site i display some links to PDF files. This links are loaded from
a database.
Anyway, when i click these links the PDF files are open in the visitors
browser and in Acrobat.

How can i force the files to be downloaded when the person clicks the link?
I don't want to use zip files.

Thank You,
Miguel

Nov 18 '05 #1
2 1268
Use Response.Writefile to output the PDF file.
http://msdn.microsoft.com/library/de...efiletopic.asp

Then add a line of code like this:
Response.AddHeader("Content-Disposition","attachment;filename=myfile.pdf");
The "attachment" specification requests the browser to download the file
instead of opening it. But ultimately it is up to the browser and the user
to decide what they want to do with the file; you don't have 100% control of
this from the server.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Miguel Dias Moura" <in************@27lamps.com> wrote in message
news:ue**************@TK2MSFTNGP09.phx.gbl...
Hello,

in my web site i display some links to PDF files. This links are loaded from a database.
Anyway, when i click these links the PDF files are open in the visitors
browser and in Acrobat.

How can i force the files to be downloaded when the person clicks the link? I don't want to use zip files.

Thank You,
Miguel

Nov 18 '05 #2
The closest Ive come to controlling this behavior is to put the PDF in
a zip file. A total kludge would be to rename the file with a pdx
extenstion and prompt the user to rename the file during the save step
to a pdf extension.
On Mon, 19 Apr 2004 13:31:10 -0700, "Steve C. Orr [MVP, MCSD]"
<St***@Orr.net> wrote:
Use Response.Writefile to output the PDF file.
http://msdn.microsoft.com/library/de...efiletopic.asp

Then add a line of code like this:
Response.AddHeader("Content-Disposition","attachment;filename=myfile.pdf");
The "attachment" specification requests the browser to download the file
instead of opening it. But ultimately it is up to the browser and the user
to decide what they want to do with the file; you don't have 100% control of
this from the server.


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matthew Sims | last post by:
Is it possible to force a download without using the readfile function? My website setup consists of my server that serves the web pages plus a high-speed file server elsewhere on the internet...
2
by: Jonathan Driller | last post by:
I am attempting to block repeat downloads from a site. I need to have a landing page pass a referer to a secured page. I have tried a meta refresh redirect and several Javascript redirect...
0
by: Jake | last post by:
How can I force an image download with IE using ASP.net?? Here is the catch: the image I want to force a write with is located on another web server. I can only reference the image with a URL. ...
2
by: JP SIngh | last post by:
Hi All I am creating an asp application which is essentially a file management app. I am trying to get my head around a technically issue wonder if someone can offer some help. I want to be...
4
by: Kevin Muenzler, WB5RUE | last post by:
How do I force a browser to download a file instead of displaying it? In other words I have a page with MP3 and WMA files on it and I would like for the visitor to download the file instead of...
4
by: tma | last post by:
Short of zipping my file, are there any other alternatives to the below? I'm trying to add anchors in code and I need the link to force a download of the .pdf rather than open a new window or...
0
by: comp.lang.php | last post by:
I have a form that when you click the "Generate Report" submit button, it will force download a CSV file, required for this project. On the very same page you also have a "Search" submit button,...
2
by: comp.lang.php | last post by:
class ReportGenerator { function ReportGenerator() {} /** * Generate the HTTP headers necessary for this file type. Can be called statically *
3
by: Bouffa | last post by:
Hello everyone, I suppose you all know force-download scripts. The problem is that these scripts don't allow files to be splitted when downloading them via a download manager. I've found a...
0
by: jinnareddy | last post by:
Hi, I'm unable to download a file that is having a 2-byte char in its name (e.g.テ) using force download option. Though, am able to download file names involving ASCII chars. I have tried URL...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.