unable to access the $_FILES when submitting a form php
<p>I was getting this weird error when submitting an image for a form upload and i could not see why the $FILES was not set as this is where the files go from a $POST back form in php.</p>
<p>The error i was getting was similar to: </p>
<h4>PHP</h4>
<pre><code class="php hljs">Notice: Trying to access array offset on value of type null<br /><br />Warning: mimecontenttype(): Can only process string or stream arguments</code></pre>
<p>So apparently the fix for this is in the form type.</p>
<p>You can add the following to your <code><form></code> element</p>
<p><code class="html hljs xml">enctype="multipart/form-data"</code></p>
<h4>HTML</h4>
<pre><code class="html hljs xml"><form method="POST" enctype="multipart/form-data">...</form></code></pre>
<p>For some reason i always forget to add this and i get this error, so im adding it here hoping that i will not forget again, but incase i do its here!</p>