fineuploader - initial file list

2019-08-25 01:35发布

I am using fineuploader (4.2) jquery version in a zf2 application. I am looking for help in getting the initial file list functionality working.

Using fineuploader to upload the files, they are physically saved in the public/client-images directory. The uuid, filename, filesize are then saved in the database.

To populate the initial file list, i have the following jquery:

<script>
  $(document).ready(function () {
    var manualUploader = $('#jquery-wrapped-fine-uploader').fineUploader({
      session : {
        endpoint : 'json/' + $("#userId").text(),  
      },
      paramsInBody : true,
      template: "qq-simple-thumbnails-template",
      thumbnails: {
          placeholders: {
            waitingPath: "/js/jquery.fineuploader-4.2.0/placeholders/waiting-generic.png",
            notAvailablePath: "/js/jquery.fineuploader-4.2.0/placeholders/not_available-generic.png"
          }
      },
      autoUpload: false,
      editFilename: {
        enabled: true
      }
    });

    manualUploader.on("sessionRequestComplete", function (event, response, success, rawData){
        alert(success);
    });

    $('#triggerUpload').click(function() {
        manualUploader.fineUploader('uploadStoredFiles');
      });
  });
</script>

I am looking at retrieving the uploaded images of userId (eg 53) with the following url: domain/images/client-images/json/53 When i manually type this url in my browser i get the following json response:

[[{"image":{"name":"IMAG0124.JPG","uuid":"913dee8e-bd0b-4fc7-ba69-83fa23c86372","size":"1336238","id":"29","user_id":53}}]]

However this response when called from fineuploader gives me the following message in firebug:

[FineUploader 4.2.0] Session response item 0 did not include a valid UUID - ignoring.

I'm assuming this is because fineuploader is looking for a directory named with the uuid and is not finding it. Is there an option that i can set that defines a "base" directory that all uuid named directories are stored in? I cannot store the full path of the directory (ie "/public/client-images/913dee8e-bd0b-4fc7-ba69-83fa23c86372") as the uuid in the database, as the json response escapes the backslashes/directory separators.

1条回答
Viruses.
2楼-- · 2019-08-25 02:31

You are not returning a proper response to Fine Uploader's GET initial files request.. Fine Uploader is looking for an array of objects. You are returning an array of an array of objects.

查看更多
登录 后发表回答