Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. how to force file download?

how to force file download?

Scheduled Pinned Locked Moved Web Development
htmltutorialquestion
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    m rastgar
    wrote on last edited by
    #1

    i have a static html page. i have a link in it to download a pdf file. i want to force download the file, not to open it, when user click on it. but if user had installed acrobotreader in his/her pc, my link open the file directly. but i dont want to act so. i want file to be downloaded. thanks rastgar

    C B D 3 Replies Last reply
    0
    • M m rastgar

      i have a static html page. i have a link in it to download a pdf file. i want to force download the file, not to open it, when user click on it. but if user had installed acrobotreader in his/her pc, my link open the file directly. but i dont want to act so. i want file to be downloaded. thanks rastgar

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You can't force anything with a static HTML page, I don't believe.  You'd have to zip the file.

      Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

      M 1 Reply Last reply
      0
      • C Christian Graus

        You can't force anything with a static HTML page, I don't believe.  You'd have to zip the file.

        Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

        M Offline
        M Offline
        m rastgar
        wrote on last edited by
        #3

        how about with javascript? Thanks Rastgar

        V 1 Reply Last reply
        0
        • M m rastgar

          how about with javascript? Thanks Rastgar

          V Offline
          V Offline
          Vasudevan Deepak Kumar
          wrote on last edited by
          #4

          You can't go too far with JavaScript either. You can open in a new window.

          Vasudevan Deepak Kumar Personal Homepage Tech Gossips

          1 Reply Last reply
          0
          • M m rastgar

            i have a static html page. i have a link in it to download a pdf file. i want to force download the file, not to open it, when user click on it. but if user had installed acrobotreader in his/her pc, my link open the file directly. but i dont want to act so. i want file to be downloaded. thanks rastgar

            B Offline
            B Offline
            Bradml
            wrote on last edited by
            #5

            On your server try configing the HTTP headers to include the "Content-disposition" header.


            Brad Australian - Christian Graus on "Best books for VBscript" A big thick one, so you can whack yourself on the head with it.

            1 Reply Last reply
            0
            • M m rastgar

              i have a static html page. i have a link in it to download a pdf file. i want to force download the file, not to open it, when user click on it. but if user had installed acrobotreader in his/her pc, my link open the file directly. but i dont want to act so. i want file to be downloaded. thanks rastgar

              D Offline
              D Offline
              David Domingues
              wrote on last edited by
              #6

              just call a javascript function with an open command to the link in onclick event. Example: open("download/file.pdf","_blank"); this will ask you if you want to open or save.

              Contact me! Please feel free to visit my site

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups