<?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: File upload and validation</title>
		<link>https://legacy.forums.gravityhelp.com/topic/file-upload-and-validation</link>
		<description>Gravity Support Forums Topic: File upload and validation</description>
		<language>en-US</language>
		<pubDate>Sun, 05 Apr 2026 15:34:58 +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/file-upload-and-validation" rel="self" type="application/rss+xml" />

		<item>
			<title>andreyu on "File upload and validation"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-upload-and-validation#post-42033</link>
			<pubDate>Wed, 23 Nov 2011 16:39:07 +0000</pubDate>
			<dc:creator>andreyu</dc:creator>
			<guid isPermaLink="false">42033@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks,. that did the trick.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Alex Cancado on "File upload and validation"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-upload-and-validation#post-41918</link>
			<pubDate>Tue, 22 Nov 2011 17:49:13 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">41918@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;The problem is that uploaded files are not available in the $_POST variable. You need to use $_FILES instead. However, if there are any validation errors in the form, Gravity Forms will have already uploaded the file and it won't be available in the $_FILES variable anymore. In that case you will need to check the $_POST variable.&#60;br /&#62;
The following code snippet should do the trick for you.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//Note: Replace 1 in &#38;quot;input_1&#38;quot; with your actual file upload field id.
$uploaded_files = json_decode(rgpost(&#38;quot;gform_uploaded_files&#38;quot;));
$is_file_uploaded = !empty($_FILES[&#38;quot;input_1&#38;quot;][&#38;quot;name&#38;quot;]) &#124;&#124; isset($uploaded_files-&#38;gt;input_1);&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>andreyu on "File upload and validation"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-upload-and-validation#post-41872</link>
			<pubDate>Tue, 22 Nov 2011 11:19:50 +0000</pubDate>
			<dc:creator>andreyu</dc:creator>
			<guid isPermaLink="false">41872@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I'm trying to make some text fields mandatory UNLESS the user selects a file in a separate file upload field.&#60;/p&#62;
&#60;p&#62;I've used the gform_validation hook to perform custom validation and I've run into a pretty big problem: the value of the file upload field isn't available in my validation function. The file I selected isn't anywhere in the $_POST array. Here's what happens:&#60;/p&#62;
&#60;ol&#62;
&#60;li&#62;
I select a file and click the submit button
&#60;/li&#62;
&#60;li&#62;
The custom validation kicks in. It can't find the value for the file input field so returns errors.
&#60;/li&#62;
&#60;li&#62;
I change nothing in the fields and click the submit button again
&#60;/li&#62;
&#60;li&#62;
Now the field value is ok, the validation checks and I'm allowed to continue
&#60;/li&#62;
&#60;/ol&#62;
&#60;p&#62;I tried setting the file upload field as &#34;required&#34;, just to see what would happen and everything is ok. That is strange to me, as I thought that gform_validation was triggered AFTER the normal validation. So it's weird that the normal validation has access to the field value, but my function doesn't.&#60;/p&#62;
&#60;p&#62;Any help would be greatly appreciated...thanks!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
