In MOSS 2007, profile pictures are stored in personal Mysites of the corresponding users. Due to this users cannot upload profile pictures when “Personal Site” creation in turned off at SSP level.
This article describes on how to upload/change profile pictures without personal site.
Note: In SharePoint 2010, profile pictures are stored in a centralized location (public Mysite), following approach is a mimic of 2010 functionality.
Follow these steps:
1. Create a picture library “Profile Pictures” in MiSite central site collection (public mysite).
2. Develop a User Control with ASPUpload control and two buttons.
3. On button click of upload picture, upload the selected picture to “Profile Pictures” library (Used SID of the user to create the picture).
string userName = SPContext.Current.Web.CurrentUser.LoginName;
SPPictureLibrary oPicLib = (SPPictureLibrary)SPContext.Current.Web.Lists[“Profile Pictures”];
Stream fileStream = fileProfilePicture.PostedFile.InputStream;
byte imageData = new byte[fileStream.Length];
fileStream.Read(imageData, 0, System.Convert.ToInt32(fileStream.Length));
4. Once the picture is uploaded to the library, set image to “PictureUrl” property in SharePoint User Profile Store.
ServerContext context = ServerContext.GetContext(SPContext.Current.Web.Site);
UserProfileManager mngr = new UserProfileManager(context);
UserProfile oProfile = mngr.GetUserProfile(SPContext.Current.Web.CurrentUser.LoginName);
oProfile[“PictureUrl”].Value = strImagePath;
This way user can able to change his/her profile picture when personal site creation is disabled.