 <p>The first question has already been answered so I won't answer it again.</p> <blockquote> <p>2) it redirects to upload_file.php and displays a message. Is there a way to actually go back the main page and display text that it was successful?</p> </blockquote> <p>It is normally better to show the success message on the redirected page but you can solve this two ways:</p> <ul> <li>Store the previous URL (or know it) and redirect to it with <code>header("Location: old_page.php");</code></li> <li>Make the target of the form an iframe. This means the main page itself will not redirect and you can just bubble a response from upload_file.php (which will load in the iframe) making seamless uploading for your app.</li> </ul> <p>Also this is not the best way to get a file extension:</p> <pre><code>$extension = end(explode(".", $_FILES["file"]["name"])); </code></pre> <p>Try using pathinfo instead: <a href="http://php.net/manual/en/function.pathinfo.php">http://php.net/manual/en/function.pathinfo.php</a></p> <pre><code>$extension = pathinfo( $_FILES["file"]["name"], PATHINFO_EXTENSION); </code></pre> <p>And your <code>if</code> statement:</p> <pre><code>if ($extension!=".doc" || $extension!=".doc" &amp;&amp; ($_FILES["file"]["size"] &lt; 200000) &amp;&amp; in_array($extension, $allowedExts)) { </code></pre> <p>Even though this is a tiny usage of <code>in_array</code> I still would recommend taking that out and using a more practical method of searching arrays: <a href="http://php.net/manual/en/function.array-search.php">http://php.net/manual/en/function.array-search.php</a></p> <p>So your <code>if</code> would become something like:</p> <pre><code>if (($_FILES["file"]["size"] &lt; 200000) &amp;&amp; array_search($extension, $allowedExts)!==false) { </code></pre>