<?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: Issue with multiple files attachment</title>
		<link>https://legacy.forums.gravityhelp.com/topic/issue-with-multiple-files-attachment</link>
		<description>Gravity Support Forums Topic: Issue with multiple files attachment</description>
		<language>en-US</language>
		<pubDate>Thu, 16 Apr 2026 02:44:42 +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/issue-with-multiple-files-attachment" rel="self" type="application/rss+xml" />

		<item>
			<title>miguel on "Issue with multiple files attachment"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/issue-with-multiple-files-attachment#post-73298</link>
			<pubDate>Thu, 30 Aug 2012 12:31:07 +0000</pubDate>
			<dc:creator>miguel</dc:creator>
			<guid isPermaLink="false">73298@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thank you @Chris Hajer.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>vostn on "Issue with multiple files attachment"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/issue-with-multiple-files-attachment#post-73262</link>
			<pubDate>Thu, 30 Aug 2012 10:22:24 +0000</pubDate>
			<dc:creator>vostn</dc:creator>
			<guid isPermaLink="false">73262@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;@miguel&#60;/p&#62;
&#60;p&#62;Thank you, this worked great!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Issue with multiple files attachment"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/issue-with-multiple-files-attachment#post-73233</link>
			<pubDate>Thu, 30 Aug 2012 07:15:28 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">73233@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;@miguel:&#60;/p&#62;
&#60;blockquote&#62;&#60;p&#62;
The code is being showed a little strange in my first post (I think I didn't use the correct format for publish code on this forum)
&#60;/p&#62;&#60;/blockquote&#62;
&#60;p&#62;I fixed the formatting by removing the extraneous HTML.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>miguel on "Issue with multiple files attachment"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/issue-with-multiple-files-attachment#post-73197</link>
			<pubDate>Wed, 29 Aug 2012 21:36:13 +0000</pubDate>
			<dc:creator>miguel</dc:creator>
			<guid isPermaLink="false">73197@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi vostn,&#60;/p&#62;
&#60;p&#62;First of all, I'm sorry for the delay of my answer, I didn't get a notification of your reply =)&#60;/p&#62;
&#60;p&#62;You can just copy/paste the second block of code that I pasted and use it as is in your functions.php. The first block is the one that is suggested on the documentation, but as I said, it has functionality issues.&#60;/p&#62;
&#60;p&#62;The code is being showed a little strange in my first post (I think I didn't use the correct format for publish code on this forum) so I will add it again, just copy/paste the following:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;[php]
add_filter(&#38;quot;gform_admin_notification_attachments&#38;quot;, &#38;quot;add_attachment&#38;quot;, 10, 3);
function add_attachment($attachments, $lead, $form){
	$fileupload_fields = GFCommon::get_fields_by_type($form, array(&#38;quot;fileupload&#38;quot;));
	if(!is_array($fileupload_fields)){
		return $attachments;
	}
	$attachments = array();
	$upload_root = RGFormsModel::get_upload_root();
	foreach($fileupload_fields as $field){
		$url = $lead[$field[&#38;quot;id&#38;quot;]];
		$attachment = preg_replace(&#38;#39;&#124;^(.*?)/gravity_forms/&#124;&#38;#39;, $upload_root, $url);
		if($attachment){
			$attachments[] = $attachment;
		}
	}
	return $attachments;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Finally, answering your question of attach images to email and don't save them in Wordpress, it is possible, but that's a different topic. Browse the forum to see if there's a topic about it, or publish a new one.&#60;/p&#62;
&#60;p&#62;Best,
&#60;/p&#62;</description>
		</item>
		<item>
			<title>vostn on "Issue with multiple files attachment"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/issue-with-multiple-files-attachment#post-71855</link>
			<pubDate>Tue, 21 Aug 2012 09:33:31 +0000</pubDate>
			<dc:creator>vostn</dc:creator>
			<guid isPermaLink="false">71855@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I have up to 6 attachment fields, none of which are required, so any number could be used. Is this the code I would need to use? (And I'm a total amateur at this... so would I just be copying and pasting the above code as is into functions.php (no changes)?&#60;/p&#62;
&#60;p&#62;I was also wondering if there's a way to attach uploaded files to the notification email without saving them into WordPress. We'd like to have them come straight to us rather than piling up on our website.&#60;/p&#62;
&#60;p&#62;Thanks for any help!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>miguel on "Issue with multiple files attachment"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/issue-with-multiple-files-attachment#post-70610</link>
			<pubDate>Fri, 10 Aug 2012 15:21:05 +0000</pubDate>
			<dc:creator>miguel</dc:creator>
			<guid isPermaLink="false">70610@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi guys!&#60;/p&#62;
&#60;p&#62;I was using the example that you wrote on the gform_admin_notificacion_attachments documentation (&#60;a href=&#34;http://www.gravityhelp.com/documentation/page/Gform_admin_notification_attachments)&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/documentation/page/Gform_admin_notification_attachments)&#60;/a&#62;. It works great! but after a few tests I realize something:&#60;/p&#62;
&#60;p&#62;If you have (for example) 5 file upload fields, and you only attach 2 (the 5 file fields are marked as not required... so, is ok to attach only 2), no one file will be attached!&#60;/p&#62;
&#60;p&#62;The problem is that in the example, $attachments will be returned as an array of 5 indexes, indexes 0 and 1 will have the path of each image, but indexes 2, 3 and 4 will be isset but empty. That seems to cause that no one attachment is sent.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
&#38;lt;?php
add_filter(&#38;quot;gform_admin_notification_attachments&#38;quot;, &#38;quot;add_attachment&#38;quot;, 10, 3);
function add_attachment($attachments, $lead, $form){
    $fileupload_fields = GFCommon::get_fields_by_type($form, array(&#38;quot;fileupload&#38;quot;));
    if(!is_array($fileupload_fields))
        return $attachments;
    $attachments = array();
    $upload_root = RGFormsModel::get_upload_root();
    foreach($fileupload_fields as $field){
        $url = $lead[$field[&#38;quot;id&#38;quot;]];
        $attachments[] = preg_replace(&#38;#39;&#124;^(.*?)/gravity_forms/&#124;&#38;#39;, $upload_root, $url);
    }
    return $attachments;
}
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;To fix this, I made a little change to the function:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
&#38;lt;?php
add_filter(&#38;quot;gform_admin_notification_attachments_4&#38;quot;, &#38;quot;add_attachment&#38;quot;, 10, 3);
function add_attachment($attachments, $lead, $form){
	$fileupload_fields = GFCommon::get_fields_by_type($form, array(&#38;quot;fileupload&#38;quot;));
	if(!is_array($fileupload_fields)){
		return $attachments;
	}
	$attachments = array();
	$upload_root = RGFormsModel::get_upload_root();
	foreach($fileupload_fields as $field){
		$url = $lead[$field[&#38;quot;id&#38;quot;]];
		$attachment = preg_replace(&#38;#39;&#124;^(.*?)/gravity_forms/&#124;&#38;#39;, $upload_root, $url);
		if($attachment){
			$attachments[] = $attachment;
		}
	}
	return $attachments;
}
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Now the returned array has only the 2 indexes with images, and the images are sent to the email.&#60;/p&#62;
&#60;p&#62;I hope this would be helpful to somebody as it was for me.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
