Results 1 to 7 of 7

Thread: Want Download To Open

  1. #1
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    212
    Thanks
    77
    Thanked 3 Times in 3 Posts

    Default Want Download To Open

    Hi Folks, and Happy New Year or (if you prefer), happy Groundhog Day.

    Here's my question: When I link to a .pdf file, the .pdf file downloads. The user than has to find the downloaded file and open it, in order to see it. It is also possible that the user does not even realize that the requested file has downloaded. Here is an example of the pertinent code that I am using:

    HTML Code:
    aware of those difficulties, and are able to <a href="2c52d14e1brf.pdf" target="_blank">help steer applicants through these rocky shoals</a>.
    Is there a way to force the linked file to open (assuming, of course, that the visitor has .pdf software)?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I did that both on my localhost server and on my domain. The file doesn't download. It displays in a new tab in the browser. I think this is set in the browser, but might be set on the server. Try my example and see what happens:

    http://jscheuer1.com/demos/tidbits/dlpdf.htm

    Here's my page's code:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    </head>
    <body>
    <a href="some.pdf" target="_blank">Some PDF</a>
    </body>
    </html>
    In any event, I think the trick is to force a download when the browser is configured to display the file. But I could be mistaken. I tried all major browsers, they all displayed the file.
    Last edited by jscheuer1; 02-02-2018 at 04:19 AM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    212
    Thanks
    77
    Thanked 3 Times in 3 Posts

    Default

    John,

    Thanks for your answer. (Glad to see you're still here upon my own return after a palpable absence.)

    As best I can tell, your html code appears functionally equivalent to mine. For some reason, I see a difference in action between your code and mine. (That would tend to rule out server setting.) Your code opens a new tab in the browser, containing a link to your .pdf file. The file itself downloads only when I click on the link in the new tab. With my code, a new tab opens momentarily then after about a half second, disappears. The .pdf file itself downloads. It opens only when I click on it.

    I'm missing something.

    A.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Wait a second, you're saying that basically the same code on my server does what you want, and that when it is on your server it doesn't do what you want? If that's what you're saying, then it's most likely some server configuration. But I didn't think that was possible, I thought to force a pdf download you needed a special page with the download headers. I'm not really up on all the latest with this though, or even all the oldest.

    Anyways, if you get one result on one server (mine), and a different result on a different server (yours) with the same HTML code and the same browser, then it's probably the server. The only other things I can think of are headers (is your page PHP?), or possibly doctype or meta tags.

    However, if you're only testing your code on the hard drive, that might be the explanation - Browsers often react differently to code that is not live.
    Last edited by jscheuer1; 02-02-2018 at 02:55 PM. Reason: add info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    marain (02-02-2018)

  6. #5
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    212
    Thanks
    77
    Thanked 3 Times in 3 Posts

    Default

    These are .php files, and I've tried it only using the server, and only using FF 58.0.1 (32 bit). The page in question is https://www.njexpungements.com/faq.php. An area that demonstrates the situation I've been describing is the last two paragraphs of the answer to Question 30. Clicking on the links to .html files opens a new window (nothing strange there). Clicking on the link to a .pdf file behaves as indicated in my earlier posts.

    Were I overlooking something obvious or easily discerned, I would have made the necessary changes. As it is, the problem is insufficiently irksome for me to delve more deeply. I am prepared to accept your surmise that the explanation lies within the server.

    A.

  7. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,497
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well I don't have that version of Firefox. I have 57.0 (64 bit). And in it and all other major browsers your link opens in a new tab as desired. So it's likely the browser. It may be set to download PDF of a certain size and larger. It is a pretty sizable PDF file. In any case, I would hazard most users have it open for them in a new tab.

    Oh, and just updated to Firefox 58.0.1 (64 bit) also fine in that.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #7
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,810
    Thanks
    48
    Thanked 237 Times in 230 Posts
    Blog Entries
    55

    Default

    John and Marain, I also have FF 58.0.1 (32 bit), but with this browser-version, the PDF does not behave here like Marain says. The PDF-file opens and stays there, waiting for a click on it to be downloaded.
    To avoid PDF-issues related to the use of certain browsers or Operating Systems, I always use the Google Document Viewer for displaying PDF, see this.
    Edit: I may have misunderstood the question. If so, please remove my post.
    Last edited by molendijk; 02-05-2018 at 07:35 PM.

Similar Threads

  1. Resolved Force link to download image not open
    By davelf in forum HTML
    Replies: 6
    Last Post: 05-31-2012, 03:17 AM
  2. Replies: 1
    Last Post: 03-11-2010, 07:13 PM
  3. Download page help! (download.php)
    By Patel123 in forum PHP
    Replies: 4
    Last Post: 01-29-2010, 01:49 PM
  4. Popup File download window that closes when download button clicked
    By amccann in forum Looking for such a script or service
    Replies: 5
    Last Post: 10-27-2007, 01:37 PM
  5. Download .jpg (not open it)
    By ExSpirit in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 06-28-2006, 07:18 AM

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
  •