Protected File Downloads

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jerryyang_la1@yahoo.com

    #1

    Protected File Downloads

    Hi.

    I'm looking for a way to allow users to download files, but what files
    they see and can download need to be restricted to their username..

    I will have a couple of users who will have full access, the others
    need to see only the files I have allocated to them.

    Can this be done ?

    Any scripts available to do this ?

    Thanks

  • Erwin Moller

    #2
    Re: Protected File Downloads

    jerryyang_la1@y ahoo.com wrote:
    [color=blue]
    > Hi.
    >[/color]

    Hi,
    [color=blue]
    > I'm looking for a way to allow users to download files, but what files
    > they see and can download need to be restricted to their username..[/color]

    If their username is a unix username (real user) than .htaccess could be of
    use.
    If the users are unrelated (eg Database-stored) to systemusers, you'll have
    to use PHP to deliver the file.

    [color=blue]
    >
    > I will have a couple of users who will have full access, the others
    > need to see only the files I have allocated to them.
    >
    > Can this be done ?
    >[/color]

    Yes.

    Just place the files in a directory where nobody can access them directly
    via a http-request.
    Let PHP, once you agreed that the user should be ok, read the file and give
    it to the user.
    So the PHP-user (on *nix often: apache, or nobody, or www-data) should of
    course have read-right on all the files for this to work.
    [color=blue]
    > Any scripts available to do this ?[/color]

    No idea. Quite basic stuff.
    You can roll your own.
    Have a look at www.php.net, and look for fopen() and the other
    filefunctions.

    [color=blue]
    >
    > Thanks[/color]

    Good luck.

    Regards,
    Erwin Moller

    Comment

    • Jerry Stuckle

      #3
      Re: Protected File Downloads

      Erwin Moller wrote:[color=blue]
      > jerryyang_la1@y ahoo.com wrote:
      >
      >[color=green]
      >>Hi.
      >>[/color]
      >
      >
      > Hi,
      >
      >[color=green]
      >>I'm looking for a way to allow users to download files, but what files
      >>they see and can download need to be restricted to their username..[/color]
      >
      >
      > If their username is a unix username (real user) than .htaccess could be of
      > use.
      > If the users are unrelated (eg Database-stored) to systemusers, you'll have
      > to use PHP to deliver the file.
      >[/color]

      You don't have to be a unix username to be available in .htaccess. mod_auth
      will handle non-unix names also. For a few files and a few users, this would be
      pretty easy. But as the number of files and users increases, it can become more
      difficult to administer.

      How to set this up would be better asked in alt.apache.conf iguration.
      [color=blue]
      >
      >[color=green]
      >>I will have a couple of users who will have full access, the others
      >>need to see only the files I have allocated to them.
      >>
      >>Can this be done ?
      >>[/color]
      >
      >
      > Yes.
      >
      > Just place the files in a directory where nobody can access them directly
      > via a http-request.
      > Let PHP, once you agreed that the user should be ok, read the file and give
      > it to the user.
      > So the PHP-user (on *nix often: apache, or nobody, or www-data) should of
      > course have read-right on all the files for this to work.
      >[/color]

      Yep, either place it before the website root directory or protect the directory
      with .htaccess.

      If it's going to be a lot of files with a lot of users, I would recommend
      managing access in a database. By this I don't mean to use the database itself
      to manage the security; rather use it in your PHP code to identify who can
      access what).
      [color=blue]
      >[color=green]
      >>Any scripts available to do this ?[/color]
      >
      >
      > No idea. Quite basic stuff.
      > You can roll your own.
      > Have a look at www.php.net, and look for fopen() and the other
      > filefunctions.
      >[/color]

      I agree. This is something that's just faster to write yourself than 1) Search
      the internet, 2) Determine which is closest to your needs, 3) Understand the
      code so that you can 4) Modify it to meet your exact needs.
      [color=blue]
      >
      >[color=green]
      >>Thanks[/color]
      >
      >
      > Good luck.
      >
      > Regards,
      > Erwin Moller[/color]


      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      Working...