how to configure jquery file upload plugin -


i trying use jquery file upload plugin ruby on rails upload files. below things objectives.

  • able drag , drop multiple files

  • i can send single file @ time. having 10 files means plugin should send 1 one file name filedata.

  • after selecting files, can removed before sending server.

  • and should show file upload progress

but using sample code, when try drag , drop files, sending 1 file server , not showing file name in filepreview. if autoupload enabled, sending selected file. still not showing filename in filepreview. remove selected file got suggestion here. after clicking start upload button getting javascript error. says "ncaught typeerror: cannot read property 'size' of undefined". please on issue. in advance.

sample code here.

<%= javascript_include_tag 'application/jquery.ui.widget' %>  <%= javascript_include_tag 'application/jquery.iframe-transport' %>  <%= javascript_include_tag 'application/jquery.fileupload' %>  <script type="text/javascript">      $('#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(                      $('<span>').text(file.name)                      .append('<a class="removebutton" href="#"> <img src="/oldimages/note_deletebut.png"/> </a>')                      .attr('id', 'filespan')                      .append($('<br>'))                  );              });          },          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)          }      });  </script>  <form id="file-form" enctype="multipart/form-data" method="post" name="fileinfo">      <div class="upload-droparea fnt6c"> drop files here<br>or <br>          <span class="btn btn-default orngbtn lesbtn filesbg uplod-btn">              <span>select files</span>              <input type="file" id="filedata" name="filedata" multiple>          </span>      </div>      <div id="filepreview"></div>      <button id="triggerupload" value="start upload" class="btn btn-default orngbtn lesbtn filesbg" type="button">start upload      </button>      <button data-dismiss="modal" id="cancelupload" value="cancel" class="btn btn-default orngbtn lesbtn filesbg" type="button">cancel</button>  </form>

i've got same error (on line 116 in fileupload-ui.js). there error in template, resulted in more indexes pictures added, leading data element undefined


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -