<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — Functions to prevent unwanted file types on file upload.]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=5105&amp;type=atom" />
	<updated>2014-08-22T04:26:29Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=5105</id>
		<entry>
			<title type="html"><![CDATA[Re: Functions to prevent unwanted file types on file upload.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=20551#p20551" />
			<content type="html"><![CDATA[<p>Yes, I agree with your opinion.&nbsp; So, here I changed it as per my view, </p><p>&lt;pre&gt;<br />//-----------------------------------------------------------------------------------<br />function file_cells($label, $name, $id=&quot;&quot;, $file_type=null)<br />{<br />&nbsp; &nbsp; if ($id != &quot;&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; $id = &quot;id=&#039;$id&#039;&quot;;<br />&nbsp; &nbsp; &nbsp; &nbsp; echo $file_type ; <br />&nbsp; &nbsp; if($file_type== &#039;documents&#039; ){<br />&nbsp; &nbsp; &nbsp; &nbsp; $accept = &#039;.doc,.docx, .rtf, .txt, .pdf, .ppt, .pptx&#039; ;<br />&nbsp; &nbsp; } elseif($file_type== &#039;image&#039; ){<br />&nbsp; &nbsp; &nbsp; &nbsp; $accept = &#039;image/*&#039; ;<br />&nbsp; &nbsp; } elseif( $file_type=&#039;video&#039;) {<br />&nbsp; &nbsp; &nbsp; &nbsp; $accept =&#039;video/*&#039; ;<br />&nbsp; &nbsp; } else <br />&nbsp; &nbsp; &nbsp; &nbsp; $accept = &#039;&#039;; <br />&nbsp; &nbsp; &nbsp; &nbsp; <br />&nbsp; &nbsp; label_cells($label, &quot;&lt;input type=&#039;file&#039; name=&#039;$name&#039; $id&nbsp; accept=&#039;$accept&#039; $file_type /&gt;&quot;);<br />}&nbsp; &nbsp; &nbsp; &nbsp; <br />function file_row($label, $name, $id = &quot;&quot;, $file_type=null)<br />{<br />&nbsp; &nbsp; echo &quot;&lt;tr&gt;&lt;td class=&#039;label&#039;&gt;$label&lt;/td&gt;&quot;;<br />&nbsp; &nbsp; file_cells(null, $name, $id, $file_type);<br />&nbsp; &nbsp; echo &quot;&lt;/tr&gt;\n&quot;;<br />}&nbsp; &nbsp; <br />&lt;/pre&gt;</p><p>Here, you can input 4th parameter as the acceptable file type, and my code, i used three different things, </p><p>documents - doc, docx, rtf, txt, pdf, ppt, pptx, </p><p>image -&nbsp; all image types, which supported by html 5</p><p>video - all video file types, which supported by HTML5.</p><p>and final one is empty, Thats one for default use, it will support all file types,</p>]]></content>
			<author>
				<name><![CDATA[kvvaradha]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=19348</uri>
			</author>
			<updated>2014-08-22T04:26:29Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=20551#p20551</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Functions to prevent unwanted file types on file upload.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=20524#p20524" />
			<content type="html"><![CDATA[<p>Are you referring to lines 674 to 685 in <strong>includes/ui/ui_input_inc.php</strong> :<br /></p><div class="codebox"><pre><code>function file_cells($label, $name, $id=&quot;&quot;)
{
    if ($id != &quot;&quot;)
        $id = &quot;id=&#039;$id&#039;&quot;;
    label_cells($label, &quot;&lt;input type=&#039;file&#039; name=&#039;$name&#039; $id /&gt;&quot;);
}        
function file_row($label, $name, $id = &quot;&quot;)
{
    echo &quot;&lt;tr&gt;&lt;td class=&#039;label&#039;&gt;$label&lt;/td&gt;&quot;;
    file_cells(null, $name, $id);
    echo &quot;&lt;/tr&gt;\n&quot;;
}    </code></pre></div><p>If so, then an optional extra parameter (with any as default if omitted for backward compatibility) for various file type groups can be introduced to avoid any more functions.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2014-08-21T19:00:35Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=20524#p20524</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Functions to prevent unwanted file types on file upload.]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=20521#p20521" />
			<content type="html"><![CDATA[<p>here, i just changed it based on my convinent for the attachements, while uploading images of a product, we dont need to allow peoples to choose, some other file types, such as doc&#039;s and exe&#039;s. <br />in certain case its become vulnerable to our FA. So we should avoid choosing different file types, before selecting it.&nbsp; Eventhough we can check it while processing form submission. but this one avoids attaching some other files type, here i changed the file_row() based on images , pdf, and doc, just try these functions,</p><p>//-----------------------------------------------------------------------------------<br />function kv_image_cells($label, $name, $id=&quot;&quot;)<br />{<br />&nbsp; &nbsp; if ($id != &quot;&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; $id = &quot;id=&#039;$id&#039;&quot;;<br />&nbsp; &nbsp; label_cells($label, &quot;&lt;input type=&#039;file&#039; name=&#039;$name&#039; $id&nbsp; accept=&#039;image/*&#039;/&gt;&quot;);<br />}&nbsp; &nbsp; &nbsp; &nbsp; <br />function kv_image_row($label, $name, $id = &quot;&quot;)<br />{<br />&nbsp; &nbsp; echo &quot;&lt;tr&gt;&lt;td class=&#039;label&#039;&gt;$label&lt;/td&gt;&quot;;<br />&nbsp; &nbsp; kv_image_cells(null, $name, $id);<br />&nbsp; &nbsp; echo &quot;&lt;/tr&gt;\n&quot;;<br />}&nbsp; &nbsp; </p><br /><p>//-----------------------------------------------------------------------------------<br />function kv_doc_cells($label, $name, $id=&quot;&quot;)<br />{<br />&nbsp; &nbsp; if ($id != &quot;&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; $id = &quot;id=&#039;$id&#039;&quot;;<br />&nbsp; &nbsp; label_cells($label, &quot;&lt;input type=&#039;file&#039; name=&#039;$name&#039; $id&nbsp; accept=&#039;.doc,.docx&#039;/&gt;&quot;);<br />}&nbsp; &nbsp; &nbsp; &nbsp; <br />function kv_doc_row($label, $name, $id = &quot;&quot;)<br />{<br />&nbsp; &nbsp; echo &quot;&lt;tr&gt;&lt;td class=&#039;label&#039;&gt;$label&lt;/td&gt;&quot;;<br />&nbsp; &nbsp; kv_doc_cells(null, $name, $id);<br />&nbsp; &nbsp; echo &quot;&lt;/tr&gt;\n&quot;;<br />}&nbsp; &nbsp; </p><p>//-----------------------------------------------------------------------------------<br />function kv_pdf_cells($label, $name, $id=&quot;&quot;)<br />{<br />&nbsp; &nbsp; if ($id != &quot;&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; $id = &quot;id=&#039;$id&#039;&quot;;<br />&nbsp; &nbsp; label_cells($label, &quot;&lt;input type=&#039;file&#039; name=&#039;$name&#039; $id&nbsp; accept=&#039;.pdf&#039;/&gt;&quot;);<br />}&nbsp; &nbsp; &nbsp; &nbsp; <br />function kv_pdf_row($label, $name, $id = &quot;&quot;)<br />{<br />&nbsp; &nbsp; echo &quot;&lt;tr&gt;&lt;td class=&#039;label&#039;&gt;$label&lt;/td&gt;&quot;;<br />&nbsp; &nbsp; kv_pdf_cells(null, $name, $id);<br />&nbsp; &nbsp; echo &quot;&lt;/tr&gt;\n&quot;;<br />}</p>]]></content>
			<author>
				<name><![CDATA[kvvaradha]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=19348</uri>
			</author>
			<updated>2014-08-21T08:58:30Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=20521#p20521</id>
		</entry>
</feed>
