PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Specify upload location

  1. I'm in the process of creating a form and accompanying plugin that allows an admin to upload files independent of the Media Gallery. Yes, there's a good reason for it. :-) The upload field on the form uploads to a directory structure that differs from the Media Gallery only in that it's got an extra directory in it called "gravityforms".

    I would like to have all the uploads from this particular form to go to a single directory. As of now I have to write code to make that happen after the form is submitted. It would be really nice to have a setting that says "Here's where I'd like these files uploaded if done via this form". Default to the standard structure is fine, I'd just like to have control over it if the need arises, as it has in this case.

    Thanks.

    Posted 14 years ago on Thursday November 11, 2010 | Permalink
  2. You can already specify a new upload path via a filter added to your functions.php file.

    example:

    <?php
    add_filter("gform_upload_path", "change_upload_path", 20, 2);
    function change_upload_path($path_info, $form_id){
       $path_info["path"] = "/new/path/";
       $path_info["url"] = "http://new_url.com/images/";
       return $path_info;
    }
    ?>

    Be sure to specify the full server path to your directory, and also the full URL as well in the path variables.

    Posted 14 years ago on Thursday November 11, 2010 | Permalink
  3. Hi, Kevin,

    That's very helpful, thank you. Much easier than what I was working on. :-) Is this actually documented anywhere?

    Consider this: what if I wasn't a developer? Seems to me "ordinary people" might have a need to set the path without having to mess with code.

    In any case, I appreciate the response and the assist.

    John

    Posted 14 years ago on Friday November 12, 2010 | Permalink
  4. John,

    I'm glad that helped. I'm not sure if that's documented here or not other than a few places in the forums themselves. We do have some extensive new documentation being put together and hope to launch that soon.

    Posted 14 years ago on Friday November 12, 2010 | Permalink
  5. Hi, Kevin,

    Excellent. I look forward to seeing the new docs.

    Thanks, again, for the help.

    John

    Posted 14 years ago on Sunday November 14, 2010 | Permalink