title: Extra Large size file upload Doesn't working using PHP/HTML
body: <p>I don't want to restrict user to upload large file. User can upload any file size. When i tried file size of 22 MB, It worked. But When I tried 200MB file, it seems it does not entered in if block and return me the output of else block after taking all the time in the world to upload file.
  My work on this is mention below. Am I missing something?</p>
  
  <p>HTML: </p>
  
  <pre><code>&lt;form method="post" enctype="multipart/form-data" class="form-horizontal"  role="form"&gt;
  &lt;label for="document"&gt;Upload your Document&lt;/label&gt;
  &lt;input type="file" id="document" name="document"&gt;
  &lt;label for="doc_cat"&gt;Document Category:&lt;/label&gt;
  &lt;select name="doc_cat" id="doc_cat" class="form-control" required&gt;
  &lt;option value=""&gt;--Select a Category--&lt;/option&gt;
  &lt;option value="1"&gt;Sales&lt;/option&gt;
  &lt;option value="2"&gt;Technical&lt;/option&gt;
  &lt;option value="3"&gt;Pricing&lt;/option&gt;
  &lt;option value="4"&gt;Policies&lt;/option&gt;
  &lt;option value="5"&gt;Other&lt;/option&gt;
  &lt;/select&gt;
  &lt;button type="button" class="btn btn-primary" id="upload" name="upload"&gt;Upload&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JQUERY/AJAX:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $('#upload').click(function () {
              var formData = new FormData($('form')[0]);
              var that = this;
              $.ajax({
                  url: 'upload-document-proccess.php',  //Server script to process data
                  type: 'POST',
                  data: formData,
                  async: false,
                  beforeSend: function() {
                        $("#loading-image").show();
                  },
                  success: function (msg) {
                      $("#loading-image").hide();
                      $("#display-return-msg").html(msg);
                      $("#display-return-msg").fadeIn("slow").delay(5000).fadeOut("slow");
                  },
                  cache: false,
                  contentType: false,
                  processData: false
              });
          $('form')[0].reset();
          return false;
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>upload-document-proccess.php:</p>
  
  <pre><code>if(isset($_POST) &amp;&amp; $_FILES['document']['size'] &gt; 0)
  {
      $category_id = $_POST['doc_cat'];
      $doc_desc = htmlspecialchars($_POST['doc_desc'],ENT_QUOTES);
      switch ($category_id) {
          case 1:
              $category="Sales";
              break;
          case 2:
              $category="Technical";
              break;
          case 3:
              $category="Pricing";
              break;
          case 4:
              $category="Policies";
              break;
          case 5:
              $category="Other";
              break;
          default:
              # code...
              break;
      }
  
      $target_dir = "uploads/";
      $target_file = $target_dir . basename($_FILES["document"]["name"]);
  
      $fileName = $_FILES['document']['name'];
      $tmpName  = $_FILES['document']['tmp_name'];
      $fileSize = $_FILES['document']['size'];
      $fileType = $_FILES['document']['type'];
  
      $fp      = fopen($tmpName, 'r');
      $content = fread($fp, filesize($tmpName));
      $content = addslashes($content);
      if (move_uploaded_file($_FILES["document"]["tmp_name"], $target_file)) {
          $msg = "The file ". basename( $_FILES["document"]["name"]). " has been uploaded to ".$category." Category";
      } else {
          echo "Sorry, there was an error uploading your file.";
      }
      fclose($fp);
  
      if(!get_magic_quotes_gpc())
      {
          $fileName = addslashes($fileName);
      }
  
      try {   
          $sql = "INSERT INTO document (doc_name, doc_type, doc_size, user_id, doc_category_id, doc_date, doc_desc)
          VALUES ('$fileName', '$fileType', '$fileSize', '$user_id', '$category_id', now(), '$doc_desc')";
          // use exec() because no results are returned
          $conn-&gt;exec($sql);
          ?&gt;&lt;script type="text/javascript"&gt;
          var msg = '&lt;?php echo $msg; ?&gt;';
              $(document).ready(function(){
                  $("#display-return-msg").html(msg);
                  $("#display-return-msg").fadeIn("slow").delay(5000).fadeOut("slow");
              });
          &lt;/script&gt;
          &lt;?php
          }
      catch(PDOException $e)
          {
          echo $sql . "&lt;br&gt;" . $e-&gt;getMessage();
          }
      //echo "&lt;br&gt;File $fileName uploaded&lt;br&gt;";   
  }else{
      echo "Please select File to upload.";
  }
  ?&gt;
  </code></pre>
  
  <p>In '#display-return-msg' id, It gives me "Please select File to upload" when i uploaded 200MB file. When i uploaded 22 MB file, I got value of 'msg' variable which is correct. Please suggest me What do i do?</p>