www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: prompt for save or open a pdf or doc file

  1. #1
    Join Date
    Jan 2007
    Posts
    7

    prompt for save or open a pdf or doc file

    hi everyone..
    i have an application where there are .doc,.pdf,.zip files attached and have links to those files..
    but when i click on those links they are straight away opened in the browser window.. but i want the browser to prompt whether to open or save to a target in the local machine..
    how can i do it.. by the way i cant zip all the files so that anyhow it'l ask for save or open the file..

    if anyone has an idea of what to do for this pls reply..

    is it something to do with the server or in the local machines of the users.. or is it a javascript solution..

    waiting for your prompt reply..
    Thanx in advance..

  2. #2
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    It is in the configuration of the browser. The internet options or preferences (depending on which browser you are using) has a list file types that can be handled by the plugins installed in the browser or by the browser itself. Anything that matches that list will be handled within the browser, anything that doesn't will be offered for download.

    For Internet Explorer you need to go to "Tools", "Internet Options", "Programs", "Manage Add-ons" to see and edit the list.
    Last edited by felgall; 01-02-2007 at 04:10 AM.
    Stephen

  3. #3
    Join Date
    Jan 2007
    Posts
    7
    Thanx for your prompt reply felgall

    i think you are correct but the client wants the every user who uses this site to be able to prompt for that action whether to open or save..

    cant we do anything abt it from our side to make it happen in the client's desired way??

    thanx again for replying so soon..

  4. #4
    Join Date
    Jan 2007
    Posts
    7
    and by the way in my IE - "Tools", "Internet Options", "Programs" doesnt have anything called "Panage Add-ons"..

    if you can guide me how to do it through a script, that would be so great.. so that all the users who use the site can priviledge the facility..
    Thanx again..

  5. #5
    Join Date
    Jun 2006
    Posts
    472
    Quote Originally Posted by rukrlf
    and by the way in my IE - "Tools", "Internet Options", "Programs" doesnt have anything called "Panage Add-ons"..

    if you can guide me how to do it through a script, that would be so great.. so that all the users who use the site can priviledge the facility..
    Thanx again..
    That should be Manage Add Ons and no you cannot dictate how individuals download files, some set their browsers to automatically download to a specific folder or to prompt to save to a specific folder...change your browser setting to prompt to save then tell your client that you fixed it

  6. #6
    Join Date
    Jan 2007
    Posts
    7
    Thanks dude..
    but the prob is he watching it in some other machine..
    dont u think that there is a way to do it using javascripts??

    Thanks again...

  7. #7
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    The browser owner has the final say in how their browser works. If they don't want to run javascript then they turn it off. If they don't want Javascripts to perform certain tasks then they add their own Javascripts to undo what the ones on the page do. If they don't like the way your page looks they can define their own CSS to get it looking the way they want. The only thing a web page author controls is the content. Everything else is just a suggestion and your visitor does it how they like and if you try to block therm from doing what they want they will leave and tell everyone how horrible your site is.
    Stephen

  8. #8
    Join Date
    Sep 2005
    Posts
    137
    I had some success using window.location to prompt people to download or save pdf's or zips etc.

  9. #9
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,972
    Quote Originally Posted by rukrlf
    ...can[']t we do anything ab[ou]t it from our side to make it happen in the client's desired way?
    If you can, send it with a MIME type of application/octet-stream, then in most cases the browser should go for a save-as dialogue.
    Disclaimer. (1) Whilst I will help you sometimes, if I feel like it, and my advice in relation to your actual question will be of good quality: my posts are to be taken with a pinch of salt. I will be sarcastic, deploy irony and include obscure cultural references for my own amusement without warning.
    (2) You will gain nothing from complaining, and if you try to argue with me then you will not win. No matter how noble your battle seems, I am still better than you, don't be an hero.

  10. #10
    Join Date
    Jan 2007
    Posts
    7
    Quote Originally Posted by the tree
    If you can, send it with a MIME type of application/octet-stream, then in most cases the browser should go for a save-as dialogue.
    could you pls tell me how can i do it.. where should i change the code??

    thanks so much in advance..

  11. #11
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    Most people don't like it when you try to override their choice on how they have configured their browser to work and so if they have configured it to be able to view particular document types in their browser they will get annoyed if you try to force a download instead.

    To set the MIME type you simply specify the appropriate value in a header record for the page. How you do this depends on which server side scripting language you are using to generate the page. It can't be done with plain HTML.
    Stephen

  12. #12
    Join Date
    Jan 2007
    Posts
    7
    Quote Originally Posted by felgall
    Most people don't like it when you try to override their choice on how they have configured their browser to work and so if they have configured it to be able to view particular document types in their browser they will get annoyed if you try to force a download instead.

    To set the MIME type you simply specify the appropriate value in a header record for the page. How you do this depends on which server side scripting language you are using to generate the page. It can't be done with plain HTML.
    Actually felgall i'm not forcing the user to download the doc or pdf, i just want to prompt the user to choose either open it on the browser then and there or else if he wants he should have the facility of saving it to the computer as well.. so i thought it is more user friendly than just opening up the document then and there.. b'coz there can be users with slow connections and if it try to open quite a big file then the browser will get stuck wouldnt it??, by providing both the options i think it is much better so that he/she can choose what is the most appropriate action..

    actually what happens when the the plugin is not there is poping up a dialog box asking whether to open or save isnt it?? what i want to do is exactly the same..(rather my client wants)..

    im using ASP as the server side language.. so how can i accomplish it with ASP??

    all your thaughts were very useful and i highly appriciate your concern..

    Thanx again..

  13. #13
    Join Date
    Mar 2005
    Location
    Sydney, Australia
    Posts
    7,974
    To do it with ASP you could just write out a header setting Content-Disposition: to attachment rather than inline which instructs the browser to offer the file for download.

    Code:
    Response.AddHeader "Content-Disposition", "attachment"
    Just remember that the header has to be written before any of the actual page content.
    Stephen

  14. #14
    Join Date
    Jan 2007
    Posts
    7
    sorry for troubling you this much sir..
    but how can i write out the header setting to the attachment?? coz when i wrote it on the top of the page, it asks to download the '.asp' page..
    my '.doc' , '.pdf' files are straight away attached to the "<a href>" links..

    pls be kind enough to clear my self up..

    i know i'v been a real nuisance.. pls hold ur nerves for this question..
    Thanks alot..

  15. #15
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    You can't do it from a straight link.
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles