We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31902
    • 342 Posts
    As I've always understood it, in MODx's default state, a user who wants to upload an image in order to use it on the site will go through a series of steps to do so. As I understand it, a partial list of these steps involve (while using TinyMCE editor):

    1. Click the Insert/Edit Image button on the TinyMCE editor
    2. In the resulting box, select the Browse button next to the Image URL field
    3. The resulting box displays the contents of the account on the server at the root level.
    4. The user then navigates the server to the exact location he or she wants the image to upload to.
    5. Hopefully, if the computer-challenged editor finds the correct directory to upload to and highlights it...
    6. ...Clicks the Upload Files icon at the top, which pops up yet another box, this one to start the process of finding the desired image on the user's local machine.
    7. Another series of steps to find it involve clicking the "Choose file(s)" button which then starts the process of finding the image on the user's local machine...

    ...anyway, as you know, there are more steps involved to finish. Not hard to do when you finally memorize all the steps but this method ultimately winds up having the editor upload images to an unintended directory or location, usually right in the root.

    Is there a way to limit an editor to only be able to upload to a single particular directory? For instance, only be able to upload to something like assets/images/on-page-images/?

    I'm assuming it would be a permissions thing? What would be the exact steps to implement such a thing?

    I've experimented with the "Simple File Upload TV" snippet and it works okay for adding a particular image within a particular location on a page but it doesn't go far enough to police the general uploading of images to a single particular location in order to use in various parts of the page.

    Thank you in advance.

    Using Revo 2.4.0-pl
      • 48532
      • 23 Posts
      Have you read this thread https://forums.modx.com/thread?thread=74386?

      Short version: use media sources and define a user specific setting for tinyMCEs default_media_source.
      Quote from: warsteiner80 at May 11, 2012, 06:25 AM
      JannieB, TinyMCE uses default Media source (it's defined in system settings, the key is default_media_source).
      Edit the user you want to use «resources» Media source in TinyMCE, open Settings tab, then Create new. Put default_media_source into Key and ID of your Media source in Value.
      Or, you can just set default_media_source in System settings for everybody.
        • 31902
        • 342 Posts
        Thank you Just_nico for responding. I just read your suggested link. To be honest, my pea brain didn't fully understand it. However, using it as a jumping off point, I did come up with the following steps. For all I know, it is the same thing as what is presented in that post. Please correct me if I'm wrong.

        This works for me (as used in MODx Revo v. 2.4.0-pl) but haven't had time to find any bugs in this. Please let me know if I shouldn't be following these steps:

        1. Go to Media > Media Sources

        2. Click "Create New Media Sources" button and fill in name desired and choose "File System" from Source Type dropdown. Click Save.

        3. Right-click new media source just created and select "Update Media Source." Click Save.

        4. Fill in basePath and baseUrl with path to desired directory. Click save.

        5. Navigate to System Settings.

        6. Search for "default_media_source" (without quotes).

        7. Change value (dropdown) to name of newly created media source.

        Again, thanks for responding. If anyone can confirm this to be the correct way to do this, can you please confirm here? If so, I would like to flag this post as the correct answer. [ed. note: waizen last edited this post 11 years, 1 month ago.]
          • 37377
          • 64 Posts
          You also have to change the permissions for the default mediasource (Filesystem) in order to prevent users from accessing it.
            • 31902
            • 342 Posts
            Can you clarify how/where to do this? Thanks in advance.
              • 37377
              • 64 Posts
                • 42562
                • 1,145 Posts
                If you desire an alternative:
                Use elFinder to manage your files.

                1. Open elFinder within TinyMCE or without TinyMCE
                2. User sees destination and drags and drops file from within server or from computer.
                (if two steps is to rapid, you may right-click in any destination to 'upload')

                elFinder comes with muliple volumes, much like MODx' media sources.
                Each volume is a predefined destination accessible to people of a specified usergroup; this is where you can restrict assets/images/on-page-images/
                In this case, a user is NEVER misled.

                If you install TinymceWrapper, you get the above functionality instanta.
                You also get ability to create user specific folder on the fly for each user - in this case, user will not be able to upload to another location
                  TinymceWrapper: Complete back/frontend content solution.
                  Harden your MODX site by passwording your three main folders: core, manager, connectors and renaming your assets (thank me later!)
                  5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.