We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14617
    • 47 Posts
    Hi all

    I am utilizing FileDownload and FileDownloadPlugin to let users browse through some files. I am also using FileUpload to let users upload files to the current directory. Now all I need is a way to allow the user to create a new directory (folder).

    Does anyone know if this has already been made? Or have an idea about how to implement it?

    All help is greatly appreciated.

    Jonas
      • 14617
      • 47 Posts
      no one?
        • 10449
        • 956 Posts
        I never used the FileUpload snippet myself, but I just downloaded it and read the readme.txt file.

        Apparently, it is possible to create a new directory with an optional parameter &createpath=`1`:

        * $path (mandatory)
        * path where the files should be stored. This path is relative to the siteroot.
        * Make sure that the rights for that folder are setup correctly so that PHP is
        * allowed to write in that folder. Example: $path=`/assets/uploads/` to put the
        * uploaded files in the "assets/uploads" folder.
        *
        * $createpath = 0
        * When set to 1 the path will automatically be created if it does not exist.
        * Creating of the path might fail when permissions are not set correctly.

        i.e. you could use
        [!FileUpload? &tpl=`FileUploadForm`&path=`/assets/uploads/users/foo/`&uploadgroups=`Uploaders`&extensions=`doc,xls,pdf` &createpath=`1`!]

        The question is: Do you really want the user to name a folder himself? I would suggest you define it somehow dynamically for the user, e.g. folder-name = webuser-id. This will make sure one user can’t accidentally overwrite someone else’s files, and you don’t need to validate the input (security checks for special characters etc.).
          • 14617
          • 47 Posts
          Thanks for the reply.

          The createpath parameter is unfortunately not good enough for me as the users has to be able to make their own "directory tree". Also I need it to be very very easy to use (browse to where you want the file - then upload).

          Thanks though...
            • 10449
            • 956 Posts
            No idea how to do this... But try asking in the snippet’s own support forum: http://modxcms.com/forums/index.php?topic=5889