title: how to configure jquery file upload plugin
body: <p>I am trying to use <a href="http://blueimp.github.io/jQuery-File-Upload/" rel="nofollow noreferrer">jquery file upload</a> plugin with ruby on rails to upload files. The below things are my objectives. </p>
  
  <ul>
  <li><p>Able to drag and drop multiple files</p></li>
  <li><p>I can send only single file at a time. I am having 10 files means the plugin should send one by one with the file name filedata.</p></li>
  <li><p>After selecting files, it can be removed before sending to server.</p></li>
  <li><p>And it should show the file upload progress</p></li>
  </ul>
  
  <p>But using the sample code, when i try drag and drop files, it is sending only one file to server and does not showing the file name in filePreview. If the autoupload is enabled, it is sending all the selected file. But still it is not showing filename in filePreview. To remove selected file i got suggestion from <a href="https://stackoverflow.com/questions/21337300/blueimp-file-upload-remove-a-file-from-file-list-before-upload">here</a>. But after clicking start upload button i am getting javascript error. it says "ncaught TypeError: Cannot read property 'size' of undefined". Please help on this issue. Thanks in advance.</p>
  
  <p>sample code is here.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;%= javascript_include_tag 'application/jquery.ui.widget' %&gt;
  &lt;%= javascript_include_tag 'application/jquery.iframe-transport' %&gt;
  &lt;%= javascript_include_tag 'application/jquery.fileupload' %&gt;
  &lt;script type="text/javascript"&gt;
      $('#filedata').fileupload({
          options: {
              singleFileUploads: false,
              sequentialUploads: true,
              autoUpload: false,
              dropZone: $('#file-form')
          },
          change: function (ev, data) {
              $.each(data.files, function (index, file) {
                  alert('Selected file: ' + file.name);
                  alert('Selected file size: ' + file.size);
                  $("#filePreview").append(
                      $('&lt;span&gt;').text(file.name)
                      .append('&lt;a class="removeButton" href="#"&gt; &lt;img src="/oldimages/note_deletebut.png"/&gt; &lt;/a&gt;')
                      .attr('id', 'fileSpan')
                      .append($('&lt;br&gt;'))
                  );
              });
          },
          add: function (e, data) {
              $(".removeButton").click(function() {
                 $(this).parent().remove();
                 data.files.splice(0,1); //To test
              });
              $("#triggerUpload").off('click').on('click',function () {           
                  data.submit();
              });
          },
          formData: {
          },
          url: "URL",
          done: function (e, data) {
              console.log("success")
              console.log(data.result)
          }
      });
  &lt;/script&gt;
  &lt;form id="file-form" enctype="multipart/form-data" method="post" name="fileinfo"&gt;
      &lt;div class="upload-droparea fnt6c"&gt; Drop files here&lt;br&gt;or &lt;br&gt;
          &lt;span class="btn btn-default orngbtn lesbtn filesbg uplod-btn"&gt;
              &lt;span&gt;Select Files&lt;/span&gt;
              &lt;input type="file" id="filedata" name="filedata" multiple&gt;
          &lt;/span&gt;
      &lt;/div&gt;
      &lt;div id="filePreview"&gt;&lt;/div&gt;
      &lt;button id="triggerUpload" value="Start Upload" class="btn btn-default orngbtn lesbtn filesbg" type="button"&gt;Start Upload
      &lt;/button&gt;
      &lt;button data-dismiss="modal" id="cancelUpload" value="Cancel" class="btn btn-default orngbtn lesbtn filesbg" type="button"&gt;Cancel&lt;/button&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>