Using Username as Upload folder Support
Using Username as Upload folder
Question:
How can I use the Username as a name for a folder to upload to?
Answer:
In some situations, it might be convenient to have a user upload files to a specific folder for that user only. To be able to create this situation, two assumptions will be made:
- The user first logs in before he can upload any files.
- The login is created using the standard Dreamweaver Log In User behavior
A unique value that is available after a user is logged in, is a Session Variable called MM_UserName.
First create a form and put in a File field that will be used to select the file to upload. Set up the Insert behavior if you want to add this to a database. Then start the Pure ASP Upload 3 extension. On the General tab, fill in everything like you are used to. In the Upload Folder field, select a main folder which should contain all the folders that will be created for the users to upload to. Next add the text &Session("MM_Username") behind it.
Click OK to close the Pure ASP Upload 3 window. Upload the page. If a user now logs in and uploads a file, it will be uploaded to a folder that is named after the Username that the user logged in with!
Make sure that the correct rights are set to the main folder and let these rights be inherited to any subfolders. In that case, if any user logs in for the first time and uploads a file, the unique folder for that user will be created automatically.
Be careful when using the Username as a name for an Upload folder, when a user can change his/her Username. If a user chooses to do so, the uploads from the previous folder/Username will no longer be available!
Without the standard Dreamweaver Log In User behavior, it will still be possible to achieve the above. The only thing that needs be known is if a Session Variable is created and if yes, with which name. If no Session Varible is created, this should be accomplished first.
Give it a try and see what happens! I'd really appreciate your feedback on your results! If you have any questions just let me know!
Comments
Be the first to write a comment
You must me logged in to write a comment.