SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to allow user download php file in our server?

    I want user download some php file in server.

    How can I write script?

    Thanks.
    I live in Thailand. My English grammar not well.

  2. #2
    SitePoint Member
    Join Date
    Apr 2003
    Location
    germany
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if u place the script outside of the document root of the server it should be downloadable if u supply a relative link to the file "../../somedirectory/ur.php"

    or do u want to enable users to upload files to your server?

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2002
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alternatively, use Winzip to compress the file, thus changing the extension to .zip which won't be parsed.

    A third way (if you're using a Unix/Linux server) is to choose a folder to put all your downloadable scripts in and add a .htaccess file to it, switching off the .php parsing for that directory only. A line like:

    AddType application/octet-stream .php

    should do it.

  4. #4
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thansk.
    I want user download php file from server.
    I can use file only in document root.

    I never use .htaccess before.
    Can I use header() to set some property and allow user to download?
    I live in Thailand. My English grammar not well.

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2002
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To change the MIME type? Wouldn't you have to use header() in the file you wanted to download? Good question. Try it

  6. #6
    SitePoint Addict itsource's Avatar
    Join Date
    Jun 2001
    Location
    Thailand
    Posts
    369
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know what exactly code?

    I'm not sure.
    I live in Thailand. My English grammar not well.

  7. #7
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or you could write a PHP script to allow you to download PHP documents...

    behold

    PHP Code:
    <?php
     
    header
    ('Content-Type: text/plain');
    header('Content-Disposition: attachment; filename="SomeFile.php"');
     
    readfile('./SomeFile.php');
     
    ?>

    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  8. #8
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rename the file with a .phps extension and it will come up as color coded PHP... They can the cut and paste the PHP into their own file.
    Aaron Brazell
    Technosailor



  9. #9
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    assuming PHP is installed as a Module and .phps is setup that would be a good way to do it.
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.


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
  •