<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>MachForm Community Forums Topic: limit attachment types</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: limit attachment types</description>
<language>en</language>
<pubDate>Sat, 20 Jun 2026 15:52:22 +0000</pubDate>

<item>
<title>yuniar on "limit attachment types"</title>
<link>https://www.machform.com/forums/topic/limit-attachment-types#post-11320</link>
<pubDate>Mon, 31 Jan 2011 11:50:57 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">11320@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;What version of MachForm are you using? As of version 2, there is no need to do the above hack. You only need to modify config.php file to restrict file types.
&#60;/p&#62;</description>
</item>
<item>
<title>Page on "limit attachment types"</title>
<link>https://www.machform.com/forums/topic/limit-attachment-types#post-11317</link>
<pubDate>Mon, 31 Jan 2011 06:33:15 +0000</pubDate>
<dc:creator>Page</dc:creator>
<guid isPermaLink="false">11317@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;This was just what I was looking for but unfortunatly, I got an error from it.  It breaks the form with the notice below.&#60;/p&#62;
&#60;p&#62;&#34;Parse error: syntax error, unexpected $end in /home/myaddress/includes/post-functions.php on line 2906&#34;&#60;/p&#62;
&#60;p&#62;Is there a tweek that will fix this?&#60;/p&#62;
&#60;p&#62;Thanks!
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "limit attachment types"</title>
<link>https://www.machform.com/forums/topic/limit-attachment-types#post-985</link>
<pubDate>Fri, 07 Mar 2008 10:17:04 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">985@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;ooops..sorry for the late response then.&#60;/p&#62;
&#60;p&#62;ok, if anyobody need this, all you need to do is to edit your &#60;strong&#62;includes/post-functions.php&#60;/strong&#62; file.&#60;/p&#62;
&#60;p&#62;Search around line 811 and you'll find this code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//if validation passed, store uploaded file info into array
if($_FILES[$element_name][&#38;#39;size&#38;#39;] &#38;gt; 0){
	$uploaded_files[] = $element_name;
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
Replace that code with this one:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//start file type checking -----------------
$allowed_file_types = array(&#38;quot;doc&#38;quot;,&#38;quot;pdf&#38;quot;,&#38;quot;txt&#38;quot;);                                      

if(!empty($_FILES[$element_name][&#38;#39;name&#38;#39;])){
	$file_name = strtolower($_FILES[$element_name][&#38;#39;name&#38;#39;]);
	$file_ext  =  substr($file_name, strrpos($file_name, &#38;#39;.&#38;#39;) + 1);                                              

	if(!in_array($file_ext,$allowed_file_types)){
		$error_elements[$element_id] = &#38;quot;Sorry this filetype is not allowed.&#38;quot;;
	}else{
		//if validation passed, store uploaded file info into array
		if($_FILES[$element_name][&#38;#39;size&#38;#39;] &#38;gt; 0){
			$uploaded_files[] = $element_name;
		}
	}
}
//end file type checking -------------------&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;&#60;code&#62;&#60;/code&#62;&#60;br /&#62;
and you are set.&#60;/p&#62;
&#60;p&#62;The code above would limit the file upload to *.doc, *.pdf and *.txt&#60;br /&#62;
To limit another file type, simply change this line:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;$allowed_file_types = array(&#38;quot;doc&#38;quot;,&#38;quot;pdf&#38;quot;,&#38;quot;txt&#38;quot;);&#60;/code&#62;
&#60;/p&#62;</description>
</item>
<item>
<title>merriwhether on "limit attachment types"</title>
<link>https://www.machform.com/forums/topic/limit-attachment-types#post-969</link>
<pubDate>Thu, 06 Mar 2008 18:54:17 +0000</pubDate>
<dc:creator>merriwhether</dc:creator>
<guid isPermaLink="false">969@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Thanks for your post, unfortunately as I was under time constraints to get the form up and running I chose an open source option&#60;/p&#62;
&#60;p&#62;Not ideal as I had to build the form in the 'traditional' way but it got the job done.&#60;/p&#62;
&#60;p&#62;Perhaps you'd consider making the code publicly viewable so if anyone comes along and needs to have this feature before making a purchase, the information would be here and you won't have lost another sale! :)&#60;/p&#62;
&#60;p&#62;I will be watching this product though as it looks to be very good indeed and I may have future need of it, so thanks in advance and best of luck with the product!
&#60;/p&#62;</description>
</item>
<item>
<title>yuniar on "limit attachment types"</title>
<link>https://www.machform.com/forums/topic/limit-attachment-types#post-952</link>
<pubDate>Thu, 06 Mar 2008 10:08:06 +0000</pubDate>
<dc:creator>yuniar</dc:creator>
<guid isPermaLink="false">952@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;At this moment, there is no built-in feature to restrict the file type of the attachments.&#60;br /&#62;
However, with some small modification, this can be done.&#60;/p&#62;
&#60;p&#62;Let me know if you need it and I'll send you the code, or I'll just post it here.&#60;/p&#62;
&#60;p&#62;In the future, this feature should be added to the form builder.
&#60;/p&#62;</description>
</item>
<item>
<title>merriwhether on "limit attachment types"</title>
<link>https://www.machform.com/forums/topic/limit-attachment-types#post-948</link>
<pubDate>Wed, 05 Mar 2008 20:08:33 +0000</pubDate>
<dc:creator>merriwhether</dc:creator>
<guid isPermaLink="false">948@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;I'm looking for a script to add attachments to a formmail and stumbled across this site.&#60;/p&#62;
&#60;p&#62;This script actually looks great though I have one concern.  I've already done a cursory search of the forums for this question but it the only place it was mentioned didn't answer my question, so here I am, asking my question! :)&#60;/p&#62;
&#60;p&#62;Right, I need to be able to upload .doc/.pdf/.txt files ONLY.  Can I define allowed file types using this script? &#60;/p&#62;
&#60;p&#62;Thanks in advance.
&#60;/p&#62;</description>
</item>

</channel>
</rss>
