Hi, I am using the file upload code at the link below to allows users to upgrade multiple files into a storage area.
http://dotnetslackers.com/community/blogs/basharkokash/archive/2007/09/11/Test.aspx
My question is how do I identify which files belong to which user??
On my site i am using ASP membership and before uploading files users must logg on.
Does this mean I can use the UserID to identify them or is there another simple wayI
I have the file upload in a simple wizard form.
Also i am coding in C sharp
Thank you
Amereto
![]() |
0 |
![]() |
You can use the logged in user, save the filename and user ID to a database table and you have a record.
Jeff
Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
![]() |
0 |
![]() |
Hi ,
thank you for the suggestion.
Could you provide an example in code how to acheive this in C Sharp.
amereto
![]() |
0 |
![]() |
Hi,
Hi,
You had better know about Membership. You can check this video: http://www.asp.net/learn/videos/video-148.aspx
1. You can drop a Login Control into web page, and it will build the membership database ASPNETDB.mdf(SQL Express) in App_Data folder. You can change the database provider by using the following link: http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx
2. Then you need drop a CreateUser Control into web page to create some users. And you can use Login Control to log in.
Login Control Sample: http://asp.net/CSSAdapters/Membership/Login.aspx
It can be implemented without C# code but HTML Code and configuration.
The quickstarts of membership you can check this for the codes: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/security/default.aspx
Hope it helps.
Vince Xu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]() |
0 |
![]() |
Hi, Thank you for the reply.
On my site I already use the create user wizard which enables users create an account and logg on.
On logging on they have access to a another form which gets information from the user about their preferences - on clicking the
finish button of this form the answers are inserted into a database table.
Within this form there is a file upload control and the files which the user attaches will be stored in a directory called "fileUploads".
What I want to happen is that in the database table, I have a column which stores the path to the files that were uploaded by the user so
I can identify which files were uploaded by which user
Could you advise on how to do this with some examples
thank you
![]() |
0 |
![]() |
Hi,
At firstly, pay attention that you can't modify the structure of tables in membership db. So the file information should be stored in other places.
And then there are two approachs can achieve your purpose.
1. Use Profile.(The best approach for you.)
You can define firstname, lastname and NTID as the attributes of users. These attributes called Profile in membership.
Profile in MemberShip is to store the information on users who can be login user or anonymous user. The information will be store in the database.
1). Configure in Web.Config. You can set <anonymousIdentification enabled="true"/> to permit all of the user use profile, and the information of it will be stored in database. The make-up "allowAnonymous=True" can allow using profile for anonymous user.
<anonymousIdentification enabled="true"/> <profile> <properties> <add name="FirstName" allowAnonymous="true"/> <add name="LastName" allowAnonymous="true"/> <add name="LastVisited" allowAnonymous="true"/> <add name="Work" allowAnonymous="true"/> <add name="Education" allowAnonymous="true"/> </properties> </profile>As to login user, you have to use the membership controls, such as Login.
2). Via Profile.FirstName = "username", you can set the value to this profile.
As to retrieving data from profile, you can use this:
Labal1.Text = "First name: " + Profile.FirstName; Label2.Text = "Work :" + Profile.Work;Befor that, you have to implement user management by using membership.
You can get more information about profile by using the following link http://www.odetocode.com/Articles/440.aspx
2. You can create some table in membership db in order to extend membership database and set the primary key as UserID which is connected with table aspnet_Users.
But this approach is not secured. My suggestion is if the approch one can't satisfy you, you can use approach two.
Hope it helps.
Vince Xu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]() |
0 |
![]() |
Hi Vince,
Thanks for the tip.
Could you explain the following.
If a logged in user uploads a file to the storage area on the server / how can I associate the file uploaded with the user?
![]() |
0 |
![]() |
Hi,
After user logged in, you can use Profile.FilePath="" to store the upload path into the profile according the username who has logged in.
It will be stored in the database. Next time, after this user logged in, you can use Profile.FilePath to get the path from database directly.
Before that, please configure the profile and attribute Profile.FilePath according to my last post.
Vince Xu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]() |
0 |
![]() |
Will this also work if user have uploaded multiple files??
![]() |
0 |
![]() |
One profile variable support one value. You need split them with some especial character like path1|path2|path3|
Vince Xu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
![]() |
0 |
![]() |