<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: My custom upload field is not posting correctly</title>
		<link>https://legacy.forums.gravityhelp.com/topic/my-custom-upload-field-is-not-posting-correctly</link>
		<description>Gravity Support Forums Topic: My custom upload field is not posting correctly</description>
		<language>en-US</language>
		<pubDate>Mon, 20 Apr 2026 03:28:03 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/my-custom-upload-field-is-not-posting-correctly" rel="self" type="application/rss+xml" />

		<item>
			<title>Alex Cancado on "My custom upload field is not posting correctly"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/my-custom-upload-field-is-not-posting-correctly#post-56973</link>
			<pubDate>Mon, 30 Apr 2012 11:16:07 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">56973@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Sorry for the delay. There aren't any lower level Gravity Forms API methods that you can use to specifically write to that table, so yea, you will need to use the wpdb class
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Design Farm on "My custom upload field is not posting correctly"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/my-custom-upload-field-is-not-posting-correctly#post-55790</link>
			<pubDate>Thu, 19 Apr 2012 10:26:58 +0000</pubDate>
			<dc:creator>Design Farm</dc:creator>
			<guid isPermaLink="false">55790@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I see. Is there a Gravity Forms API that I can use to write to that table, or will I have to use the wpdb class?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "My custom upload field is not posting correctly"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/my-custom-upload-field-is-not-posting-correctly#post-55787</link>
			<pubDate>Thu, 19 Apr 2012 10:15:39 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">55787@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Yes, the values from custom file upload fields won't automatically be added to the wp_rg_lead_detail table. Inserting it manually in the gform_after_submission hook should do the trick for you. Just remember that the field_number column should match your field ID.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Design Farm on "My custom upload field is not posting correctly"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/my-custom-upload-field-is-not-posting-correctly#post-55729</link>
			<pubDate>Wed, 18 Apr 2012 17:59:16 +0000</pubDate>
			<dc:creator>Design Farm</dc:creator>
			<guid isPermaLink="false">55729@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thank you for your reply.&#60;/p&#62;
&#60;p&#62;You were right - I was able to find the file in the $_FILES superglobal, and I'm now able to upload it to Youtube. I've run into another issue, though - my field entry isn't displaying in the Entries screen, even though I'm explicitly adding the Youtube URL to the $entry object in post submission. See the code below.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;/* Pre-submission hook: grab the Youtube field values and send them
     * to the Youtube class. */
    public static function post_gf_youtubefields($form) {
        $yt_field_array = array();

        foreach($form[&#38;quot;fields&#38;quot;] as $field) {
            if ($field[&#38;quot;type&#38;quot;] == &#38;quot;youtube&#38;quot;) {
                $yt_field_array[] = $field;
            }
        }

        foreach($yt_field_array as $field) {
            // Upload the file to Youtube.
            $yt_file =  $_FILES[&#38;#39;input_&#38;#39;.$field[&#38;#39;id&#38;#39;]][&#38;#39;tmp_name&#38;#39;];
            echo $yt_file;
            $yt_video_url = GFYoutubeUpload::upload_to_youtube($yt_file);

            // Save the field ID and URL as a key-value pair for later use.
            self::$entry_ids[$field[&#38;#39;id&#38;#39;]] = $yt_video_url;

            if (file_exists($_FILES[&#38;#39;input_&#38;#39;.$field[&#38;#39;id&#38;#39;]][&#38;#39;tmp_name&#38;#39;])) {
                unlink($yt_file);
            }
        }
    }

    /* Post-submission hook: write the Youtube URL to the now-available entry object. */
    public static function write_yt_url($entry, $form) {
        foreach (self::$entry_ids as $key =&#38;gt; $value) {
            $entry[$key] = $value;
        }
    }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I've been looking into functions like &#60;code&#62;gforms_entries_field_value&#60;/code&#62; and &#60;code&#62;gform_entry_field_value&#60;/code&#62;, but it doesn't look as though I can grab anything. (In fact, I just poked around in the wp_rg_lead databases, and it doesn't look as though any value is grabbed.)&#60;/p&#62;
&#60;p&#62;Because I'm using a file upload field, do I need to do an explicit write to the wp_rg_lead_detail database with my data? Or is the data stored/captured elsewhere?&#60;/p&#62;
&#60;p&#62;Again, I appreciate all of the help.&#60;/p&#62;
&#60;p&#62;Edit: If this would be better as a separate post, let me know.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "My custom upload field is not posting correctly"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/my-custom-upload-field-is-not-posting-correctly#post-55440</link>
			<pubDate>Mon, 16 Apr 2012 22:12:40 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">55440@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;The problem is that file upload inputs dont post their values in the $_POST variable, you need to use the $_FILES variable to access submitted file upload fields
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Design Farm on "My custom upload field is not posting correctly"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/my-custom-upload-field-is-not-posting-correctly#post-55233</link>
			<pubDate>Fri, 13 Apr 2012 20:09:22 +0000</pubDate>
			<dc:creator>Design Farm</dc:creator>
			<guid isPermaLink="false">55233@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I am creating a field type that uploads a video file to Youtube upon post submission. I plan to use a file upload input type, and upon submission grab the file data (or url/pathname) and upload it to Youtube. This is part of a client project that I have to build in three weeks.&#60;/p&#62;
&#60;p&#62;I've created a custom field by using the following hooks:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_action(&#38;quot;gform_field_input&#38;quot;, array(&#38;#39;GFYoutubeUpload&#38;#39;, &#38;#39;add_gf_fieldtype&#38;#39;), 10, 5);
add_filter(&#38;quot;gform_editor_js_set_default_values&#38;quot;, array(&#38;#39;GFYoutubeUpload&#38;#39;, &#38;#39;add_gf_def
add_action(&#38;quot;gform_editor_js&#38;quot;, array(&#38;#39;GFYoutubeUpload&#38;#39;, &#38;#39;add_gf_formeditor&#38;#39;));
add_filter(&#38;quot;gform_field_type_title&#38;quot;, array(&#38;#39;GFYoutubeUpload&#38;#39;, &#38;#39;add_gf_title&#38;#39;));
add_filter(&#38;quot;gform_add_field_buttons&#38;quot;, array(&#38;#39;GFYoutubeUpload&#38;#39;, &#38;#39;add_gf_button&#38;#39;));&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;(I also have a pre_submission handler that I've begun to write.)&#60;/p&#62;
&#60;p&#62;I've created a File input type, and I believe that I have the correct naming convention. I've posted my function below for review.) The input type is displaying correctly on the admin page and the form preview, but when I post the form, my custom field doesn't have a value associated with it. (There's nothing in $_POST corresponding to it, either.)&#60;/p&#62;
&#60;p&#62;Looking at the code below, can anybody tell me where I've gone wrong creating this input? Is there another hook that I don't know about that I need to use to handle the data I've added to the form?&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;/* Register the cusitom field type with Gravity Forms. */
    public static function add_gf_fieldtype($input, $field, $value, $lead_id, $form_id) {
        if ($field[&#38;quot;type&#38;quot;] == &#38;quot;youtube&#38;quot;) {
            $input_name = $form_id .&#38;#39;_&#38;#39;. $field[&#38;#39;id&#38;#39;];
            $css = isset($field[&#38;#39;cssClass&#38;#39;]) ? $field[&#38;#39;cssClass&#38;#39;] : &#38;#39;&#38;#39;;

            return sprintf(&#38;quot;&#38;lt;div class=&#38;#39;ginput_container&#38;#39;&#38;gt;&#38;lt;input name=&#38;#39;input_%s&#38;#39; id=&#38;#39;input_%s_%s&#38;#39; class=&#38;#39;%s&#38;#39; value=&#38;#39;&#38;#39; type=&#38;#39;file&#38;#39; /&#38;gt;&#38;lt;/div&#38;gt;&#38;quot;, $field[&#38;quot;id&#38;quot;], $form_id, $field[&#38;quot;id&#38;quot;], $field[&#38;quot;type&#38;quot;]. &#38;#39; &#38;#39; .esc_attr($css). &#38;#39; &#38;#39; .$field[&#38;#39;size&#38;#39;]);
        }

        return $input;
    }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Thank you.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
