SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Allow users to download a raw php file

    I want users to be able to download a PHP file from my server with the code still intact. They'll be then loading it on their server where it can be executed.

    Offering a standard download obviously won't work, as the file will be executed before they download it. I'd rather not rename them ".txt" or anything, as that'll cause more work (and probably some confusion) for my users.

    What is my best bet here?
    MickMel.com - My portfolio, etc.
    @mickmel - Twitter
    Google Earth Hacks - Fun stuff for Google Earth.

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code php:
    $filename="path/to/script.php";
     
    header("Content-Type: application/download");
    header("Content-Disposition: attachment; $filename");
    header("Content-Length: ".filesize($filename));
    readfile($filename);
    Saul

  3. #3
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfect, thanks!
    MickMel.com - My portfolio, etc.
    @mickmel - Twitter
    Google Earth Hacks - Fun stuff for Google Earth.

  4. #4
    SitePoint Member
    Join Date
    Aug 2006
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can of course also rename it to .phps

  5. #5
    SitePoint Evangelist -T-'s Avatar
    Join Date
    Jun 2002
    Posts
    444
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That means you will have to enable phps support in php.ini
    chrome is a wrapper that combines a browser with spyware

  6. #6
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by -T- View Post
    That means you will have to enable phps support in php.ini
    No not in php.ini, httpd.conf or .htaccess
    Code:
    AddType application/x-httpd-php-source .phps
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  7. #7
    SitePoint Addict tbakerisageek's Avatar
    Join Date
    Sep 2006
    Posts
    213
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not that the problem hasn't been solved, but you could always zip the file up and offer it in that fashion...

  8. #8
    SitePoint Addict mickmel's Avatar
    Join Date
    Feb 2001
    Location
    Marietta, GA
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tbakerisageek View Post
    Not that the problem hasn't been solved, but you could always zip the file up and offer it in that fashion...
    Yes, the problem has been solved. My issue is that I didn't want to make them do anything - just download the file and put it on their site. No renaming, no unzipping, etc.

    Anyhow, thanks again for your help. It works great!
    MickMel.com - My portfolio, etc.
    @mickmel - Twitter
    Google Earth Hacks - Fun stuff for Google Earth.


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
  •