SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    May 2005
    Location
    London
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Restricting downloads to 'Save'

    Hi All

    Does anyone know how I can prevent a user from opening an Excel file on a web page, and only allow them to Save it?

    Thanks.

    Paul
    Soft and Sound

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The web isn't about 'preventing' anything, and I doubt you can do so with any guarantees.

    However, you can strongly hint that the linked Excel document should be downloaded by making your web server serve it with an HTTP header like this,
    Code:
    Content-Disposition: attachment; filename=foo.xls
    This will display the Save As dialog in most browsers.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Zealot
    Join Date
    May 2005
    Location
    London
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that (sorry about the long delay...)

    I was trying to arrange for the dialogue box to offer only 'Save' and not the usual 'Open' and 'Save' buttons. I'll try your solution.
    Soft and Sound

  4. #4
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,837
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    You can't stop then opening the file as soon as the save finishes (which is what the Open button does).
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •