Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 29, 2008 07:03 AM by Vince Xu - MSFT
Apr 25, 2008 08:54 PM|LINK
I am humbly asking for VB code that would allow logged in users the ablility to upload pictures and videos based on their login ID. The uploaded files would be stored in the file system and a reference made in the database to the path of the files. Any
help would be greatly appreciated. I might also add that I am fairly new to ASP.NET.
Apr 26, 2008 02:31 AM|LINK
hi try using asp.net 2.0 membership classes for authentication and security. and then create a seperate table which holds the flie details and the details for who owns the files. very simple
Apr 29, 2008 07:03 AM|LINK
You had better know about Membership. You can check this video:
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:
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
If there are ready, there are several steps you can try to upload files with logged id.
1. FileUpload control you can use to upload file to server.
FileUpload.SaveAs("the path on server");
2. Membership.GetUser() can return the currect username logged in.
3. You can store the filename with userID into the database so as to know the file is uploaded by whom.
The information for this can be stored in Profile or custom DataBase.
3.1. Use Profile.
You can define uploadfilename 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.
<add name="UploadFileName" allowAnonymous="false"/>
As to login user, you have to use the membership controls, such as Login.
2). Via Profile.UploadFileName= filenameOnServer, you can set the value to this profile.
As to retrieving data from profile, you can use this:
Labal1.Text = "UploadFileName: " + Profile.UploadFileName;
Before 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
3.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.
For example, when the file uploaded, you can insert the file name on server and userID into this DataBase.
With 3.2, you can store information about mutiple files from user uploading. With 3.1,
one profile variable support one value. You need split them with some especial character like path1|path2|path3|.
Hope it helps.