Skip to main content
Known Participant
June 15, 2006
Question

File Download

  • June 15, 2006
  • 4 replies
  • 390 views
Hi, i have set of word document files in my root folder. i have to give a two link like view and download. if i click view option, document will display in the browser window. suppose if i click download option, save dialog box should open. Can any one tell the coding for open a save dialog box?

Thanks
Prashant Gupta(India,Chandigarh)
    This topic has been closed for replies.

    4 replies

    BKBK
    Community Expert
    Community Expert
    June 16, 2006
    Assuming that the word documents are in the folder, c:\myDocs\ and that one of the docs is called letter.doc, then the Coldfusion code you require is

    <cfheader name="Content-Disposition" value="inline; filename=letter.doc">
    <cfcontent type="application/msword" file="c:\myDocs\letter.doc" deletefile="no">

    If this only displays the document, you can force the browser to display the Save As dialog box by replacing the word inline with attachment.





    Inspiring
    June 15, 2006
    Its really all about how your browser is set up. If I click on a link to a word document, I get the open or save dialog box every time, but if i choose open, it still opens itself in the browser window.
    What I do for applications like that is just ask the user to Right click and choose "Save As" if you would like to save the file, and just have 1 link that is the files name, or something like that. I dont think you can make the diolog box come up without running some sort of activex control. . . .
    Good Luck,
    Mike
    Inspiring
    June 15, 2006
    It will only be viewable "in browser" in MSIE btw, and only if they have Word or the viewer installed.
    Inspiring
    June 15, 2006
    For a fast solution, I would put the doc files into a .zip file.

    The issue you are running into is because of the modern browser. The browser downloads the file locally, but auto-opens it since it recognizes the file extension. By changing the extension to a .zip file, the browser will have to download a complete copy to wherever the user indicates (as opposed to the temp directory where it is downloading and opening the file from)

    Basically, any file that the browser does not recognize, or has not been given explicit instructions on how to handle, will open a 'save as' dialog box.

    Hope this helps.