title: Upload fails in PHP using Malsup's jQuery File Upload Progress Bar
body: <p>I am using <a href="http://www.malsup.com/jquery/form/progress2.html">Malsup's jQuery File Upload Progress Bar</a> for visualizing progress bar while uploading files to server. I am using it now at present. I have got the following doubts in this plugin:</p>
  
  <p>1) File uploads even if the progress bar has not achieved 100%</p>
  
  <p>2) If the File size is more than 10 MB, it loads upto 100% in the progress bar and echoes Upload failed! message.</p>
  
  <p>Here is the code :</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;head&gt;
  &lt;title&gt;Uploads&lt;/title&gt;
  &lt;style&gt;
  body { padding: 30px }
  form { display: block; margin: 20px auto; background: #eee; border-radius: 10px; padding: 15px }
  
  .progress { position:relative; width:400px; border: 1px solid #ddd; padding: 1px; border-radius: 3px; }
  .bar { background-color: #B4F5B4; width:0%; height:20px; border-radius: 3px; }
  .percent { position:absolute; display:inline-block; top:3px; left:48%; }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;File Upload&lt;/h1&gt;
      &lt;form action="file.php" method="post" enctype="multipart/form-data"&gt;
          &lt;input type="file" name="myfile[]" multiple&gt;&lt;br&gt;
          &lt;input type="submit" value="Upload File to Server"&gt;
      &lt;/form&gt;
  
      &lt;div class="progress"&gt;
          &lt;div class="bar"&gt;&lt;/div &gt;
          &lt;div class="percent"&gt;0%&lt;/div &gt;
      &lt;/div&gt;
  
      &lt;div id="status"&gt;&lt;/div&gt;
  
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"&gt;&lt;/script&gt;
  &lt;script src="http://malsup.github.com/jquery.form.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  (function() {
  
  var bar = $('.bar');
  var percent = $('.percent');
  var status = $('#status');
  
  $('form').ajaxForm({
      beforeSend: function() {
          status.empty();
          var percentVal = '0%';
          bar.width(percentVal)
          percent.html(percentVal);
      },
      uploadProgress: function(event, position, total, percentComplete) {
          var percentVal = percentComplete + '%';
          bar.width(percentVal)
          percent.html(percentVal);
          //console.log(percentVal, position, total);
      },
      complete: function(xhr) {
          status.html(xhr.responseText);
      }
  }); 
  
  })();       
  &lt;/script&gt;
  &lt;script src="http://www.google-analytics.com/urchin.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  _uacct = "UA-850242-2";
  urchinTracker();
  &lt;/script&gt;
  </code></pre>
  
  <p>The form action -> file.php code :</p>
  
  <pre><code>&lt;?php
  $upload_directory = "../users/Files/";
  if (move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_directory . $_FILES['userfile']['name'])) {
      print "&lt;br&gt;&lt;br&gt;";
      print "&lt;font color='black'&gt;File Uploaded Successfully&lt;/font&gt;";
      print "&lt;br&gt;&lt;br&gt;";
      print "&lt;font color='black'&gt;Uploaded File is {$_FILES['userfile']['name']} and its size is {$_FILES['userfile']['size']} bytes &lt;/font&gt;";
  } else {
      print "Upload failed!";
  }
  ?&gt;
  </code></pre>
  
  <p>My server settings for File Uploads:</p>
  
  <pre><code>post_max_size            1050M   1050M
  
  upload_max_filesize  1050M   1050M
  
  upload_tmp_dir           /tmp    /tmp
  </code></pre>
  
  <p>Settings in php.ini :</p>
  
  <pre><code>max_execution_time = 30 ; Maximum execution time of each script, in seconds
  
  max_input_time = -1
  
  memory_limit = 2000M ; Maximum amount of memory a script may consume (8MB)
  </code></pre>