Allow users to upload, download and view only their own documents

Discussion in 'aMember Pro v.4' started by fgdstudio, Mar 28, 2012.

  1. fgdstudio

    fgdstudio New Member

    Joined:
    Feb 27, 2012
    Messages:
    7
    Hello, all. I've been looking at this forum and have not found this information. I'm looking for a way that users can upload documents, view them on a list, then download them, as well. I want the user to view and download only documents he or she has uploaded. These functions would be links to pages in the profile page. The user would click on the 'view documents' link to see a list of files they'd uploaded. Each file name in the list would have a link to download that particular file.

    I have scripts to upload files, create a directory, view the list of documents and download files. I think I would need to create a directory for each user, which would reside in another directory that is protected. How would I go about getting the username, user id or variable, or whatever I need to create the directory with the user's unique identifier as the name of the directory that only he or she can access? Is there a another way to do what I want, that I am missing?

    Thanks
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
  3. fgdstudio

    fgdstudio New Member

    Joined:
    Feb 27, 2012
    Messages:
    7
    Thanks for the response. I looked at the page, especially the first example, the test.php. I am still a bit confused. Can you explain it a bit, please? What value is stored in the following:
    $user = $event->getUser(); // User object

    Can I retrieve the value from this variable to use in a query? For example, SELECT login from am_user WHERE login = $user, or something like that? I may not be explaining myself very well.

    I want members to be able to upload documents, but only view the ones they have uploaded. If I create a folder called doc_uploads to store uploaded documents, and then protect it, I assume anyone who is logged in can see ALL of the documents of that folder.

    My idea is that I can have a script create a folder for each member upon upload, have it name the folder based on their login id or email, or whatever value is in $user, then protect that folder. Any documents uploaded can only be viewed by the person who uploaded it. Sounds really complicated, I know.

    Thanks, again.
  4. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    $user = $event->getUser();
    This is user object that already have all necessary variables. You can access user login this way: $user->login
  5. everbatim

    everbatim aMember Pro Customer

    Joined:
    Dec 19, 2007
    Messages:
    65
    For what it's worth, this would be a nice option or add-on for aMember. I could see how it would be useful in my business model for example. I'd love to see a brick on the dashboard that just says MY DOWNLOADS which refers to customer specific files uploaded by the admin on the back end. Almost like the user comments area in the admin area except the files WOULD be visible on the client side. So the administrator would log into the back end admin area, locate a user and click on their username. Then on the member details page (still in the back end), maybe right below the optional comments area, there could be an upload form to attach a file to THAT specific user. Attached files would appear just below that upload form on the back end and on the client side would appear in the MY DOWNLOADS brick.

    Very cool idea that I think would be useful to a LOT of people, if you think about it - makes sense!
  6. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    Thanks for the suggestion. I will add this to out bugtracker and we will implement this for sure.
  7. fgdstudio

    fgdstudio New Member

    Joined:
    Feb 27, 2012
    Messages:
    7
    I was able to use the information from the getUser() method and apply it to my upload/download scripts to allow logged-in users view their files. I'm still doing some testing, but it's mostly working the way we need it to. Thanks again.
  8. hhubbers01

    hhubbers01 aMember Pro Customer

    Joined:
    Feb 22, 2012
    Messages:
    25
    Hi there

    Would it be possbile please to share the scripts that you have created as I am trying to achieve the same thing.

    Cheers,
    Hugh
  9. jackgordon

    jackgordon aMember Pro Customer

    Joined:
    Mar 23, 2009
    Messages:
    269
  10. everbatim

    everbatim aMember Pro Customer

    Joined:
    Dec 19, 2007
    Messages:
    65
    Just FYI - aMember did implement the feature I described above, it's called Personal Content and works quite well. It doesn't allow users to upload files (at least I don't think) but it does allow admins to upload files to specific customers, where said files are only view able by the user they are assigned to.
  11. rked

    rked New Member

    Joined:
    Jun 11, 2007
    Messages:
    29
    I got the perosnal content plugin but there is no documentation for it. Its installed, but nothing comes up in dashboard for it. Please help.
  12. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    I havent used the personal content plugin on 4.x yet, but on 3.x you would create a master directory with an .htaccess file and any other default content for amember to copy into amember created member folders.

    the htaccess file content for 3.x:

    ########### AMEMBER START #####################
    AuthType Basic
    AuthName "Members Only"
    AuthUserFile /home/yoursite/public_html/amember/data/.htpasswd
    Require user <!--LOGIN-->
    ########### AMEMBER FINISH ####################



    David
  13. alex

    alex aMember Pro Customer Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,021
    No, it works differently in v4.
    I am sorry for lack of documentation, we will fix it ASAP.

    In short, once you enable the personal-content plugin, there will be a new field added at bottom of users profile at aMember CP -> Browse Users -> Edit. You may upload files using this new field.
    Users will see files you uploaded for them in the member area. http://yoursite.com/amember/member
  14. supex

    supex New Member

    Joined:
    Jul 11, 2012
    Messages:
    12
    May I know can we set the Limit Downloads Count?

Share This Page