Custom FileDialog browsing

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
4/15/2012 6:20:57 PM
Gravatar
Total Posts 8

Custom FileDialog browsing

Hey All,

Does anyone know how to make the "FileDialog" open at a given folder and use that as it's root?

Here's my scenario.

I need to give a user access to the file upload/managment dialog.  I want to do this from within a custom control (Preferably by using the FileBrowserTextBoxExtender control, or a derivitive of it) , however I need the filedialog to only open in one folder (not the users name folder) that lives in the site data folder, and not be able to go back up above that folder.

The user needs to have full create/upload/delete access on said folder.

The need behind this is to allow a person to upload zip files to a given folder only, that is then used by another person at a different location to select the uploaded file and insert a link to that file into another custom control which then builds up a specialised list of links after combining with other information from the DB.

The person entering the list items will not be at the same location that the source files will be uploaded from.

I can see that it would be fairly easy to create my own "FileBrowserTextBoxExtender" and make use of the "dir" parameter that can be passed to the "FileDialog" control, but in all the testing I've done so far the "FileDialog" seems to ignore the "dir" parameter

4/16/2012 6:56:51 AM
Gravatar
Total Posts 18439

Re: Custom FileDialog browsing

Hi Shawty,

The file dialog enforces specific folders based on role permissions. The parameter passed in the dir param must be an allowed folder beneath his allowed starting folder according to the user roles otherwise it would be a big security problem if you could just pass in any folder as a query string param. The FileBrowserTextBoxExtender isn't really part of the security because it doesn't control uploading it just links to the dialog.

I don't really have a ready made solution for you to upload and browse to an arbitrary location. From your scenario it sounds like the  person uploading doesn't need the dialog at all they just need to browse their local files and click upload and your code can put it in a specific place.

The existing file browser dialog allows admins to upload/browse beginging at the root /Data/Sites/[SiteID]

Users in General Browse and Upload Roles can upload/browse starting at the root /Data/Sites/[SiteID]/media

Users allowed to upload but only in a user specific location can upload/browse starting at /Data/Sites/[SiteID]/userfiles/[UserID]

So you could put your files in a folder under media and then the person who is making the links could browse to them using the link toolbar item in the wysiwyg editor (or using the FileBrowserTextBoxExtender) as long as he is in a general upload roles. The user who is uploading doesn't need to see where it goes and you can control where the file is stored upon upload from custom code, but putting it below media folder would make it eaiser to use built in features for the other person who is linking to the files, otherwise you would have to build your own dialog to browse and link to the file.

Hope that helps,

Joe

4/16/2012 3:03:08 PM
Gravatar
Total Posts 8

Re: Custom FileDialog browsing

Hi Joe,

Thanks for the reply, detailed as usual :-)

I think I'm probably going to go for the single page with a file upload control on, at most the uploader will need to see a list of files uploaded to this specific forced directory, so I think a simple custom control, to list what's there already with a file browse/upload button is the way to go.

What's the best way to detect (In my custom control form load) if the user browsing to the page has upload privliges in thier account, can I just use something in the user "roles" collection, or is there a specific flag/function to check?

4/17/2012 3:29:46 PM
Gravatar
Total Posts 18439

Re: Custom FileDialog browsing

Hi Shawty,

If you are controlling where the file goes and validating the file type and not letting the user who uploads browse the file system, I'm not sure you really need to check upload roles since you can control who can access the page by page view roles and thereby control who can upload.

But if you really do need to check you can do something like this:

if (WebUser.IsInRoles(siteSettings.GeneralBrowseAndUploadRoles))

Hope that helps,

Joe

4/18/2012 4:42:25 AM
Gravatar
Total Posts 8

Re: Custom FileDialog browsing

Thanks again Joe.

Where getting closer to deploying our Mojo Setup on Lidnug, the code I'm writing at the moment is to allow our event managment team to manage our event recordings.

I figured out that I can just use the normal Page/Webpart security for controlling who see's what on the page, so in the end I didn't need to do any checking "As you suspected" :-)

I'm also thinking of doing a blog post or two on my experiences with developing in Mojo, particularly with regards to updating how I've done things in an easier way under VS2010 compared to the articles you have documenting the VS2008 methods.

Lastly I'd like to ask, if you would be interested in doing a live online presentation on Lidnug and introducing MojoPortal to our member base, if you are interested then contact me directly using my email registered with this forum and we'll discuss the details.

We currently have over 48,000 members world wide, we often get attendances of around a 100 (Sometimes more depending on the topic & speaker) then afterwards every recording get's added to our dedicated Lidnug you-tube channel (Which anyone is free to browse)

PS: Forgive me asking here, but I was looking for a more direct way of putting the question to you, but couldn't find one.

Cheers

Shawty

4/18/2012 1:31:27 PM
Gravatar
Total Posts 18439

Re: Custom FileDialog browsing

Hi Shawty,

Sure, sounds like that would be a great opportunity to get some exposure for mojoPortal, seeing the Lidnug site using mojoPortal will also be good for us so I'm very excited to hear you are getting close. I'll contact you soon to discuss details.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.