I am trying to create a custom registration module,where user can upload their profile image during registration.
I have tried many tutorials but none of them seems to work.
Here is the code i am implementing:
protected void btnUserRegister_Click(object sender, EventArgs e)
{
string FileName = System.IO.Path.GetFileName(FileUploadUserImage.PostedFile.FileName);
string userName = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo().Username;
UserInfo objUser = new UserInfo();
objUser.PortalID = this.PortalId;
objUser.IsSuperUser = false;
objUser.DisplayName = txtDisplayName.Text;
objUser.Email = txtEmail.Text;
objUser.Username = txtUserName.Text;
objUser.DisplayName = txtDisplayName.Text;
UserMembership objMembership = new UserMembership();
objMembership.Approved = true;
objMembership.CreatedDate = DateTime.Now;
objMembership.Email = txtEmail.Text;
objMembership.Username = txtUserName.Text;
objMembership.Password = txtPassword.Text;
objUser.Membership = objMembership;
UserCreateStatus result = UserController.CreateUser(ref objUser);
DotNetNuke.Services.FileSystem.IFolderManager folderManager = DotNetNuke.Services.FileSystem.FolderManager.Instance;
DotNetNuke.Services.FileSystem.IFolderInfo folderInfo = folderManager.GetUserFolder(objUser);
string FolderPath = folderInfo.PhysicalPath + FileName;
System.IO.FileStream InputBin = new System.IO.FileStream(FolderPath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite);
FileInfo objFile = (FileInfo)FileManager.Instance.AddFile(folderInfo, "FileName", InputBin, true);
if (result == UserCreateStatus.Success)
{
lblMessage.Text="User Created";
}
}
But its not working.How can i upload images to user profile programmatically?.Any help will be highly appreciated