How to allow http download by php script?

Discussion in 'PHP' started by huanghh, Nov 8, 2009.

  1. #1
    When you click some files like .rar, .zip, .doc, etc, it will be automatically downloaded. But for the files like .htm, .php, etc, when you click it, it will be parsed in the browser. I'm now developing a file manager by php, and want to download the php, html files in browser.

    Just as some file manager did, when you select a file and click download button, the file will be downloaded to your computer. How do we do that by php? And do we need to change any configurations of the apache server?
     
    huanghh, Nov 8, 2009 IP
  2. tommytx

    tommytx Well-Known Member

    Messages:
    97
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #2
    Huangh,
    Did you figure this one out, I have an interest in doing something like that.
    Thanks
     
    tommytx, Nov 8, 2009 IP
  3. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #3
    What about force download using another file?

    You need to create a new file (eg : download.php)
    Pass variable to the file like download.php?file=the_php_file.php
    Think about security though.
     
    ads2help, Nov 8, 2009 IP
  4. huanghh

    huanghh Active Member

    Messages:
    89
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #4
    No, I tried that, it's not working.
     
    huanghh, Nov 9, 2009 IP
  5. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310