how to write php function to download file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mukeshrasm
    Contributor
    • Nov 2007
    • 254

    how to write php function to download file

    Hi

    I want to give user a facility to download content so how can I do it using php
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by mukeshrasm
    Hi

    I want to give user a facility to download content so how can I do it using php
    here
    Scroll down to the part about content disposition.

    Comment

    • mukeshrasm
      Contributor
      • Nov 2007
      • 254

      #3
      Originally posted by markusn00b
      here
      Scroll down to the part about content disposition.
      I tried this code
      Code:
      header('Content-type: application/pdf');
      
      // It will be called downloaded.pdf
      header('Content-Disposition: attachment; filename="book.pdf"');
      
      // The PDF source is in original.pdf
      readfile('book.pdf');
      but in the browser it shows only some garbage values.

      Comment

      • harshmaul
        Recognized Expert Contributor
        • Jul 2007
        • 490

        #4
        the browser probably hasn't got a plug in for pdf files

        Comment

        • mukeshrasm
          Contributor
          • Nov 2007
          • 254

          #5
          Originally posted by harshmaul
          the browser probably hasn't got a plug in for pdf files
          which kind of plugin browser requires and will the same doce work for text or doc file.

          Comment

          • harshmaul
            Recognized Expert Contributor
            • Jul 2007
            • 490

            #6
            which browser are you using?

            downloads available at

            Comment

            Working...