jQuery fileupload - get list of uploaded files

后端 未结 10 1768
天涯浪人
天涯浪人 2020-12-14 23:49

I\'m using the very good jquery plugin blueimp / jQuery-File-Upload

$(\'#fileupload\').fileupload({
  autoUpload: true
, filesContainer: \'#attachments_prese         


        
相关标签:
10条回答
  • 2020-12-15 00:05

    Well this is quite an old post, but this is something which worked very well for me so I thought to post it.

    1. Bind the event to FileUploader (I did it in main.js):

          $('#fileupload').bind('fileuploaddone', function (e, data) {
              FileUploadDone(e, data);
          });
      
    2. In your html file, use the following code to get the file name:

      function FileUploadDone(e, data) {
      for (x in data._response.result.files){
          if (data._response.result.files[x].error == "")
              alert(data._response.result.files[x].name);
          else
              alert(data._response.result.files[x].error);
      }}
      

    You should watch the data object in firebug. This object encapsulates most of the information.

    0 讨论(0)
  • 2020-12-15 00:07

    If, you'r using the basic-plugin asmentioned in the documentations you need to pass the data to the function in the done attribute. change this:

    stop: function (e) {
    

    to this:

    done: function (e, data) {
    

    I don't know about the stop if you get it from one of the documentations pages then I think the same applied here you can't work with data if its not available.
    Hope this help

    0 讨论(0)
  • 2020-12-15 00:11

    to get file list on upload finished:

    $('#fileupload').bind('fileuploadfinished', function (e, data) {
       console.log(data.originalFiles);
    });
    
    0 讨论(0)
  • 2020-12-15 00:13

    you can also try this

     $('#fileupload').bind('fileuploadcompleted', function (e, data) {
         var filess= data.result.files[0];
            var filenam = filess.name;
           alert(filenam);
    });
    
    0 讨论(0)
提交回复
热议问题