Code to download an image without having to right click a link?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • w33nie
    New Member
    • Jan 2007
    • 56

    #16
    Okay well I removed the image path from the database entry, but I couldn't work out where to put the path in the code..
    in Content-Disposition? or..
    [php]
    $filename = $_GET['id'];
    header("Pragma: public");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Cache-Control: private",false) ;
    header("Content-Disposition: attachment; filename=\"".ba sename($filenam e)."\";" );
    header("Content-Transfer-Encoding: binary");
    header("Content-Type: PHP Generated Data");
    header("Content-Length: ".filesize($fil ename));
    [/php]

    Not sure what you meant about the printing of the image data?

    Comment

    • w33nie
      New Member
      • Jan 2007
      • 56

      #17
      any help?

      **** word post limit.
      Last edited by ronverdonk; Apr 28 '08, 10:38 PM. Reason: no swearing in this forum!

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #18
        After the last header()
        add
        [php]
        readfile('file_ name');
        [/php]

        Regards

        Comment

        • w33nie
          New Member
          • Jan 2007
          • 56

          #19
          Nope, same result.

          & since when has damn been a swear word?

          Comment

          • Atli
            Recognized Expert Expert
            • Nov 2006
            • 5062

            #20
            Once you have sent the headers to the browser, telling it how it should treat the data you are sending, you must send the data :)

            Putting this at the end of your code should do it.
            [code=php]
            readfile($filen ame);
            [/code]

            If this isn't working, make sure that the $filename value is in fact pointing to a valid file.

            Comment

            • w33nie
              New Member
              • Jan 2007
              • 56

              #21
              aha, sweet!
              thanks, it works

              Comment

              • Markus
                Recognized Expert Expert
                • Jun 2007
                • 6092

                #22
                Originally posted by w33nie
                aha, sweet!
                thanks, it works
                I don't see why it didn't work when i told you do to the exact same thing..

                Favoritism.

                Comment

                • ronverdonk
                  Recognized Expert Specialist
                  • Jul 2006
                  • 4259

                  #23
                  Originally posted by w33nie
                  Nope, same result.
                  & since when has damn been a swear word?
                  Since a long time.
                  Originally posted by wikipedia

                  to damn (third-person singular simple present damns, present participle damning, simple past and past participle damned)

                  a. (transitive, theology) To condemn to hell.
                  b. (transitive) To put out of favor; to ruin.
                  c. (transitive) To condemn as of poor quality, harmful, unfit or illegal.
                  d. (transitive) To swear or curse.
                  Ronald

                  Comment

                  • w33nie
                    New Member
                    • Jan 2007
                    • 56

                    #24
                    I don't think anyone under 60 would be offended by the word
                    Especially when it was in reference to the minimum word limit on posts on these forums.

                    Comment

                    • ronverdonk
                      Recognized Expert Specialist
                      • Jul 2006
                      • 4259

                      #25
                      From your post I deduct that you still have got some things to learn.

                      Discussion closed.

                      moderator

                      Comment

                      Working...