Gform upload path

m (Examples)
(Parameters)
Line 25: Line 25:
:$path_info["url"] = "Full URL to upload folder";
:$path_info["url"] = "Full URL to upload folder";
-
$form
+
$form_id
-
:([[Form Object]]) The current form.
+
:(int) The current form ID
== Examples ==
== Examples ==

Revision as of 19:00, 28 June 2012

Description

This filter is executed before uploading a file (by the File Upload or Post Image fields). It can be used to change the location where uploaded files are stored.

Usage

Applies to all forms

<?php
add_filter("gform_upload_path", "upload_path", 10, 2);
?>


Applies to a specific form. In this case, form Id 5

<?php
add_filter("gform_upload_path_5", "upload_path", 10, 2);
?>

Parameters

$path_info

(Array) The upload path to be filtered. It is an associative arrays with two keys that must be specified.
$path_info["path"] = "Full physical path to upload folder";
$path_info["url"] = "Full URL to upload folder";

$form_id

(int) The current form ID

Examples

This example changes the upload path and url for the File Upload field.


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

Source Code

This filter is located in forms_model.php

Search the Documentation