title: PHP File Upload greater than upload_max_filesize and error
body: <p>How can I catch an error on a file uploaded to my web server that is greater than php upload_max_filesize?  </p>
  
  <p>My question is similar to <a href="https://stackoverflow.com/questions/757111/large-file-upload-errors-with-php">so/large-file-upload-errors-with-php</a> although my memory limit is set to 512M so the resolution that question used will not help me.</p>
  
  <p>I am trying to upload a file 6.9MB for example and my upload_max_filesize = 6M.  My script basically just stops executing and I cannot tell where or why.  Also, I have error reporting turned on.  </p>
  
  <p>Also I should note that files &lt;6MB I can upload and process correctly with the following code: </p>
  
  <pre><code>if(isset($_FILES['file']['name']) and !empty($_FILES['file']['name'])){
  
      $info = pathinfo($_FILES['file']['name']); 
      $ext = $info['extension'];
      //verify file is of allowed types 
      if(Mimetypes::isAllowed($ext)){
          if(filesize($_FILES['file']['tmp_name']) &lt;= AttachmentUploader::$maxFilesize){              
              $a = new AttachmentUploader();      //for file uploading 
              if($a-&gt;uploadFile($_FILES['file'], 'incident', $_POST['sys_id'])){
                  header("location: ".$links['status']."?item=incident&amp;action=update&amp;status=1&amp;place=".urlencode($links['record']."id=".$_POST['sys_id']));            
              }else{
                  header("location: ".$links['status']."?item=incident&amp;action=update&amp;status=-1&amp;place=".urlencode($links['record']."id=".$_POST['sys_id']));           
              }
  
          }else{      
              $errors[] = 'The file you attempted to upload is too large.  0.5MB is the maximum allowed size for a file.  If you are trying to upload an image, it may need to be scaled down.';
          }
      }else{
          $errors[] = 'The file you attempted to upload is not allowed.  Acceptable extensions: jpg, gif, bmp, png, xls, doc, docx, txt, pdf';
      }
  }else{
      $errors[] = 'Please attach a file.';
  }
  </code></pre>
  
  <p>My php.ini settings:</p>
  
  <pre><code>;;;;;;;;;;;;;;;;;;;
  ; Resource Limits ;
  ;;;;;;;;;;;;;;;;;;;
  
  max_execution_time = 7200     ; Maximum execution time of each script, in seconds
  memory_limit = 512M  ; Maximum amount of memory a script may consume (8MB)
  
  
  ;;;;;;;;;;;;;;;;
  ; File Uploads ;
  ;;;;;;;;;;;;;;;;
  
  ; Whether to allow HTTP file uploads.
  file_uploads = On
  
  ; Temporary directory for HTTP uploaded files (will use system default if not
  ; specified).
  upload_tmp_dir = /tmp
  
  ; Maximum allowed size for uploaded files.
  upload_max_filesize = 6M
  </code></pre>