title: remote server returned 400 bad request for apache2 in ubuntu
body: <p>I am doing a file upload to my server in WPF. I am not showing this code because it worked for my localhost, so it seems like my server config is bad.
  My request arrives in this php script:</p>
  
  <p><strong>upload.php:</strong>
      
  
  <pre><code>$target_dir = "/var/www/uploads/";
  $target_file = $target_dir . $reg_id ."&amp;".$to ."&amp;". basename($_FILES["file"]["name"]);
  $uploadOk = 1;
  $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
  
  
  // Check if file already exists
  if (file_exists($target_file)) {
      echo "Sorry, the file already exists.";
      $uploadOk = 0;
  }
  
  // Check if $uploadOk is set to 0 by an error    
  if ($_FILES['file']['error'] === UPLOAD_ERR_OK) { 
      if ($uploadOk == 0) {
          echo "Sorry, your file was not uploaded.";
      // if everything is ok, try to upload file
      } else {
          if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
              echo "The file ". basename( $_FILES["file"]["name"]). " has been uploaded.";
          } else {
              echo "Sorry, there was an error uploading your file to dir: $target_file.";
          }
      }
  } else { 
      throw new UploadException($_FILES['file']['error']); 
  } 
  
  class UploadException extends Exception 
  { 
      public function __construct($code) { 
          $message = $this-&gt;codeToMessage($code); 
          parent::__construct($message, $code); 
      } 
  
      private function codeToMessage($code) 
      { 
          switch ($code) { 
              case UPLOAD_ERR_INI_SIZE: 
                  $message = "The uploaded file exceeds the upload_max_filesize directive in php.ini"; 
                  break; 
              case UPLOAD_ERR_FORM_SIZE: 
                  $message = "The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form";
                  break; 
              case UPLOAD_ERR_PARTIAL: 
                  $message = "The uploaded file was only partially uploaded"; 
                  break; 
              case UPLOAD_ERR_NO_FILE: 
                  $message = "No file was uploaded"; 
                  break; 
              case UPLOAD_ERR_NO_TMP_DIR: 
                  $message = "Missing a temporary folder"; 
                  break; 
              case UPLOAD_ERR_CANT_WRITE: 
                  $message = "Failed to write file to disk"; 
                  break; 
              case UPLOAD_ERR_EXTENSION: 
                  $message = "File upload stopped by extension"; 
                  break; 
  
              default: 
                  $message = "Unknown upload error"; 
                  break; 
          } 
          echo $message;
          return $message; 
      } 
  }     
  ?&gt;
  </code></pre>
  
  <p>It is working, when my file is smaller then 2KB, very strange... Everything which is bigger, was declined immediately with error response: </p>
  
  <pre><code>Error code: BadRequest
  &lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
  &lt;html&gt;&lt;head&gt;
  &lt;title&gt;400 Bad Request&lt;/title&gt;
  &lt;/head&gt;&lt;body&gt;
  &lt;h1&gt;Bad Request&lt;/h1&gt;
  &lt;p&gt;Your browser sent a request that this server could not understand.&lt;br /&gt;
  &lt;/p&gt;
  &lt;hr&gt;
  &lt;address&gt;Apache/2.4.7 (Ubuntu) Server at 192.168.99.1 Port 8080&lt;/address&gt;
  &lt;/body&gt;&lt;/html&gt;
  The uploaded file was only partially uploaded
  </code></pre>
  
  <p>So where my error could be? Why is my request invalid when the file is bigger then 2 KB on remote server, but not localhost? I am using Apache2/PHP5 in Docker with Ubuntu 14.04, my php.ini:</p>
  
  <p>post_max_size= 1024M;
  upload_max_filesize = 1024M;
  memory_limit = 512M;</p>