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.

New feature "gform_upload_path" not working

  1. I have already updated my Gravity Forms plugin, and I'm trying to change the path of an uploaded image, I'm using the code that is in the change_log.txt:

    add_filter("gform_upload_path", "change_upload_path", 20, 2);
    function change_upload_path($path_info, $form_id){
    	$path_info["path"] = "my_new_path";
    	$path_info["url"] = "http://my_new_url/";
    	return $path_info;
    }

    As it didn't work I also used:

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

    (I have changed the path and url values for my own)

    I have noticed that this isn't working and I made the following tests:
    - First, I tried changing the priority of the filter.
    - I also tried moving the code after the filters "gform_upload_path" and "gform_post_data" (It didn't work)

    None of these tests worked, so I added a code inside the filter to see if, at least, it was beeing executed, the code was this:

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

    The print_r was never printed, so, the function change_upload_path was never executed by the filter.

    My directory has all the needed permissions, in fact, I have already saved the images with my own code but I'd like to use the default filter that you have made for avoid problems with future versions.

    Posted 14 years ago on Friday July 23, 2010 | Permalink
  2. Hello Miguel,
    First of all, thanks for the troubleshooting. You certainly did your homework.
    I copied your code and the hook did execute properly, so I am not sure what is going on.

    A couple of things you should keep in mind.
    1- This hook is executed when uploading a file, so it will only be executed when the form is submitted (not when loaded) and a file has been selected via the file upload field.
    2- Make sure your path is a full physical directory path.

    If you still are having issues with it, send me an email to alex[at]rocketgenius.com with a temp WP admin and FTP login and I will be happy to take a look and see what is wrong.

    Posted 14 years ago on Friday July 23, 2010 | Permalink
  3. semrocc
    Member

    For some reason, I have not been able to get this to work either. Is there a way to store uploads in the default Wordpress configuration?

    Posted 14 years ago on Sunday September 12, 2010 | Permalink
  4. Currently the only thing that is stored in the default WordPress configuration are Post Image uploads. We are planning on looking at how to integrate the File Upload field with the Media Library in a future release.

    Posted 14 years ago on Monday September 13, 2010 | Permalink
  5. semrocc
    Member

    Thanks Carl, a feature like that will greatly simplify managing uploads especially when deleting content.

    Posted 14 years ago on Monday September 13, 2010 | Permalink