7 Replies - 3628 Views - Last Post: 27 February 2011 - 02:16 AM

#1 Hobold  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 15-March 09

Download PDF instead of opening in browser

Posted 09 December 2010 - 11:36 AM

Hello.

I have a page in which I want to offer downloadable PDF files, but I don't know how to make it directly downloadable, instead of opening in browser on mouse click. I don't want it to open in browser because my advisor doesn't want to (enough reason, lol).

Is there any way to make it work? Javascript code, maybe?

Thanks in advance
Is This A Good Question/Topic? 0
  • +

Replies To: Download PDF instead of opening in browser

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,170
  • Joined: 08-June 10

Re: Download PDF instead of opening in browser

Posted 09 December 2010 - 11:38 AM

nope. you have to use the correct HTTP header. I think it was the Content-Disposition header.
Was This Post Helpful? 1
  • +
  • -

#3 Hobold  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 15-March 09

Re: Download PDF instead of opening in browser

Posted 22 December 2010 - 09:18 AM

Thanks for your answer, but it didn't work. I have added a header but still it doesn't pop up a download dialog, perhaps because it's in a different directory? Look how it's set:

<meta http-equiv="Content-Disposition" content="attachment; filename=Valores_Humanos_no_Desenvolvimento_Econômico.pdf">

...

<a href="Trabalhos/Valores_Humanos_no_Desenvolvimento_Econômico.pdf" target="_blank"
 >Valores humanos no desenvolvimento econ&ocirc;mico</a> 

Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,170
  • Joined: 08-June 10

Re: Download PDF instead of opening in browser

Posted 22 December 2010 - 09:23 AM

I don’t mean the content-disposition header in HTML, I meant the HTTP header. you would have to add that through the server, e.g. on Apache you would have to change the server configuration (i.e. use the .htaccess file)

something along the lines of
<IfModule mod_headers.c>

    <FilesMatch "\.pdf$">
        Header set Content-Disposition "attachment"
    </FilesMatch>

</IfModule>


This post has been edited by Dormilich: 22 December 2010 - 09:39 AM

Was This Post Helpful? 2
  • +
  • -

#5 Hobold  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 15-March 09

Re: Download PDF instead of opening in browser

Posted 22 December 2010 - 09:33 AM

Ah, ok. Thanks again

So, I don't know if it's an Apache-based server (in fact, I know nothing about the server). Is there any way to know how can I configure it without making contact with the server administration (they are probably in vacation right now)?
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3524
  • View blog
  • Posts: 10,170
  • Joined: 08-June 10

Re: Download PDF instead of opening in browser

Posted 22 December 2010 - 09:36 AM

you can simply look in the output of phpinfo(). the server version must be listed somewhere.

This post has been edited by Dormilich: 22 December 2010 - 09:37 AM

Was This Post Helpful? 1
  • +
  • -

#7 Hobold  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 15-March 09

Re: Download PDF instead of opening in browser

Posted 22 December 2010 - 10:37 AM

It's an Apache server. I have tried uploading an .htaccess file but it doesn't seem to work. I am sorry if I'm sounding dumb, but my experience with .htaccess and server configuration is really limited.

Adobe still opens the file in browser.

Thanks for your reply (again).
Was This Post Helpful? 0
  • +
  • -

#8 Guest_Naveen*


Reputation:

Re: Download PDF instead of opening in browser

Posted 27 February 2011 - 02:16 AM

Thank you, thank you so much, this worked for me.
Was This Post Helpful? 0

Page 1 of 1