Gravity forms upload path

//Change upload directory for all forms

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;
}

//Change upload directory for specific form, the "4" in the gform_upload_path_4 below is the form id and this is what you would change for the form you want to customize

add_filter("gform_upload_path_4", "change_upload_path");
function change_upload_path($path_info){
$path_info["path"] = "/new/path/";
$path_info["url"] = "http://new_url.com/images/";
return $path_info;
}

15 Comments

You must be logged in to post a comment.


  1. Hi!

    I'm the maintainer of Custom Upload Dir, a plugin that makes WordPress a bit smarter and a lot more flexible with regards to where uploaded files are stored. With it you can easily have files put into folders based on author, date, categories, post type or almost anything else.

    In short; my plugin solves exactly the same problem as you do in this post.

    I've recently added support for uploads from Gravity Forms, and Gravity Forms Advanced Uploader. I'd be very grateful if people could try running the development version of Custom Upload Dir and report in the support forums if you run into any issues.

    Thank you!

    https://wordpress.org/plugins/custom-upload-dir/


  2. functions.php, or you could package this into a plugin and put it in the plugin main file. Good luck.


  3. Question what file do I place this into?


  4. I use the following in my functions.php file

    In my ngg gallery I have a non public album where the images get uploaded to then I can sort them out into the correct albums. Gives you control over the images.

    Hope this help people out.


  5. Pretty handy information, I which gravity forms had more of this good stuff on their site.


  6. I missed that. Managed to get it working anyway with a bit of trial and error, many thanks for this post :)

    Ab


  7. If you need more help follow the 'Goto Reference Page' link in the snippet description window. I dont have any better examples handy and am swamped at work at the moment


  8. Hi. What information to I put into this to make is specific to my site? Not 100% certain what in this code I over-write, and then what exactly I put in its place?

    Could you give an example please. Say the site is amazon.com and the owner wants to store the uploads in a directory called uploads

    Thanks, Ab


  9. No, but that would be sweet to know how to pull off. If you haven't already definitely search the GF forum for this


  10. Great snippet! Many thanks!

    Any idea how I can change the upload path for one file_upload field, specifically?

    Thanks,
    jacob


  11. Hi Gordon,
    got this working a while back - you have to get the current_user->login for the wordpress user name. I'm just updating the function, then I will post it here if you like (and if I get a reminder by email!?).


  12. This is possible but i don't have any cut and paste solutions. If you check out php.net you will need this: http://php.net/manual/en/function.mkdir.php

    Typically code like this should go in functions.php


  13. This is exactly what I'm looking for...

    However, can this be set to automatically generate a path based on a logged in users username?

    For example:- User "Smithy" uploads a file ----->> It automatically creates a /smithy/ folder and uploads the file there?

    Is this possible.

    Also, please excuse my newbness but where do I actually copy/paste your code to have in functional?

    Many thanks!


  14. Good luck, the upload path is kind of a global setting for gravity forms I have not tried to refine it any further than you see here.


  15. Hi there,
    great snippets!
    Do you know where/how I can change the upload path of post images? Ideally I would also get them uploaded straight into a (new or maybe easier existing) nextgen gallery instead the standard wordpress gallery.
    Any idea how to accomplish this?

    Just changing the upload path would help already though. Then I can import the uploaded picture(s) with nextgen.
    Point me in the right direction and I give it a shot, but by no means am I a programmer!