Upload user specific images in FCK Editor of DNN

Question:I would like to be able to let users upload their pictures through the editor "FCKConfig.ImageUpload=true" but i want each user that logs in to be able to upload to their assigned areas for instance, if user1 logs in then when he uploads a picture he would upload it to the user1 in the web server and then when he browses for all pictures using fckeditor he would only be able to see the pictures under the user1 folder.

Answer:If you want to be able to set the file browsing and uploading path on the fly for each user or group you will have to use the Application("FCKeditor:UserFilesPath") variable for FCKeditor on the Page_Init event. You can also use the Session("FCKeditor:UserFilesPath"), as a matter of fact, that is what the fckeditor documentation suggests. However, with dotnetnuke i couldnt get it to work properly using the session variable so instead I used the "Application" call, i think that this is the equivalent of using the web.config except that you are doing it dynamically. Anyhow, below is an example of how I am doing it in my site, notice that I am just checking the user name for the current logged in user, I am not checking group memberships like you want:

Protected Sub Page_Init
(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
Try
Dim userCtrlr As New UserController
Dim user As UserInfo = userCtrlr.GetUser(PortalId, UserId)
Application("FCKeditor:UserFilesPath") =
Page.ResolveUrl("~/Portals/" & PortalId.ToString & "/Userfiles/FlyerImgs/" &
user.Username & "/")
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub


Make sure that you are using the "Page.ResolveUrl" otherwise the application will have problems converting the image path, and the image will not display properly.


Ref: http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/127/threadid/158276/scope/posts/Default.aspx

Comments

Imran Akram said…
I have tried that solution but it doesn't work in DNN 4.9, been looking for an alternate for sometime now but couldn't find any.

Popular posts from this blog

Use configSource attribute to manage Web.Config sections in ASP.Net 2.0

DevOps - Key Concepts - Roles & Responsibilities - Tools & Technologies

Trouble In the House of Google