SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Prompt for password to download a file.

    I want to have about 20 files available for download, each one needs a different password. Im using a VPS WHM server. I know how to password protect a directory but Im hoping theres something I can do to just a file. Preferably without a username, just a password.
    Doesnt need to be bullet proof...

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,072
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Do you have any info about the files stored in a database? If so you could add a field for password and have the server-side language (which one?) you're using check that the person is logged in and that the password they submit is the valid password. Possibly you might want to log all attempts to download a file (possibly ip address, username, date and time) so you can keep an eye out for anything suspicious
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds great but Im not really able to program that sort of thing. I only have very basic php skills..
    I was hoping there might be something within Cpanel or something I could install like a script or similar that would do it.

  4. #4
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Storing in a database is by far the most effective way to accomplish this. However if you are looking for a simple solution, try using a .htaccess file to password lock each file. Below is a simple example, change it to suit you exact needs.

    AuthUserFile /path/to/htpasswd/file/.htpasswd
    AuthName "Name of Page"
    AuthType Basic
    <Files "mypage.html">
    require valid-user
    </Files>

    Change: /path/to/htpasswd/file/.htpasswd to the full path to the .htpasswd file you have created with the login details.

    Change "mypage.html" to the filename of the page you're protecting.

    Hope that helps.
    Matlib Australian Web Hosting
    Hosting from AUD$5 per month. Domain names from AUD$19.99.

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aha that might be something I can use, thanks.

  6. #6
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can this htaccess method work with say 10 different files and a different username and password for each file though?
    Ive got it set up with 1 file and it works great, but I tried to add a second file but cant see how that would work, seems once you are logged in all the files are accessible.

  7. #7
    SitePoint Zealot
    Join Date
    Feb 2005
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AHA
    <Files "1.jpg">

    require user test

    </Files>
    <Files "2.jpg">

    require user test2

    </Files>

    The above allows multiple files with a single user/pass each


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
  •