Results 1 to 2 of 2

Thread: link to download pdf

  1. #1
    Join Date
    May 2005
    Location
    newcastle, australia
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default link to download pdf

    hi,

    just wondering if there was a way to force a "save file?" dialog to come up after clicking a link to a pdf (like when downloading exe's) instead of the pdf simply being opened in the browser window?

    cheers,
    wiklendt.

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by wiklendt
    just wondering if there was a way to force a "save file?" dialog to come up after clicking a link to a pdf
    You can try by sending two response headers, but it's not guaranteed to work.

    First, set the Content-Type header to application/octet-stream. That in itself should make most user agents download rather than show as that MIME type presents binary data, rather than something useful. Unfortunately, Microsoft seem to have a different interpretation of things than most, and will attempt to 'sniff' the real content type (this is the cause of some of its security vulnerabilities, I think).

    Secondly, set the Content-Disposition header to attachment; filename="filename.pdf". This unofficial HTTP extension is quite widely implemented and suggests that the content is meant for download with the suggested file name. Once again, Microsoft[1] spoil this somewhat by providing broken support in several versions prior to IE6.

    You can make these changes in your server configuration (or a .htaccess file, and similar), or in a server-side script. If you don't have these options available to you, then you can't do anything and it will be up to users to download the files themselves through their browser controls.

    Mike


    [1] I'm sure other browsers have broken this sort of feature, but I know that Microsoft have consistently.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •