title: How to redirect to success page after uploading file using php?
body: <p>I am trying to redirect to another page after a successful upload.</p>
  <p>So I searched for similar answers on stackoverflow but non seems to solve my problem.</p>
  <p>This is my form:</p>
  <pre><code>    &lt;form enctype=&quot;multipart/form-data&quot;
          action=&quot;&lt;?php print $_SERVER['PHP_SELF']?&gt;&quot;  method=&quot;post&quot;&gt;
      &lt;p&gt;&lt;input type=&quot;hidden&quot; name=&quot;MAX_FILE_SIZE&quot; value=&quot;9000000&quot; /&gt; &lt;input
          type=&quot;file&quot; name=&quot;pdfFile&quot; /&gt;&lt;br /&gt;
      &lt;br /&gt;
      &lt;input type=&quot;submit&quot; value=&quot;upload&quot;  /&gt;&lt;/p&gt;
      &lt;/form&gt;
  </code></pre>
  <p>This is my php which includes the header that redirects</p>
  <pre><code>&lt;?php
  if ( isset( $_FILES['pdfFile'] ) ) {
      if ($_FILES['pdfFile']['type'] == &quot;application/pdf&quot;) {
          $source_file = $_FILES['pdfFile']['tmp_name'];
          $dest_file = &quot;upload/&quot;.$_FILES['pdfFile']['name'];
  
          if (file_exists($dest_file)) {
              print &quot;The file name already exists!!&quot;;
          }
          else {
              move_uploaded_file( $source_file, $dest_file )
              or die (&quot;Error!!&quot;);
              if($_FILES['pdfFile']['error'] == 0) {
                  print &quot;Pdf file uploaded successfully!&quot;;
                  print &quot;&lt;b&gt;&lt;u&gt;Details : &lt;/u&gt;&lt;/b&gt;&lt;br/&gt;&quot;;
                  print &quot;File Name : &quot;.$_FILES['pdfFile']['name'].&quot;&lt;br.&gt;&quot;.&quot;&lt;br/&gt;&quot;;
                  print &quot;File Size : &quot;.$_FILES['pdfFile']['size'].&quot; bytes&quot;.&quot;&lt;br/&gt;&quot;;
                  print &quot;File location : upload/&quot;.$_FILES['pdfFile']['name'].&quot;&lt;br/&gt;&quot;;
                  header('Location: success.php');
              }
          }
      }
      else {
          if ( $_FILES['pdfFile']['type'] != &quot;application/pdf&quot;) {
              print &quot;Error occured while uploading file : &quot;.$_FILES['pdfFile']['name'].&quot;&lt;br/&gt;&quot;;
              print &quot;Invalid  file extension, should be pdf !!&quot;.&quot;&lt;br/&gt;&quot;;
              print &quot;Error Code : &quot;.$_FILES['pdfFile']['error'].&quot;&lt;br/&gt;&quot;;
          }
      }
  }
  ?&gt;
  </code></pre>