Fine Uploader无法传递自定义参数


Fine Uploader cannot pass custom paramaters

我已经用这个消息发了好几个小时了,无法让它工作。我的应用程序的微调

$(document).ready(function() {
//alert(qq.supportedFeatures.ajaxUploading);
  $('#fine-uploader-house').fineUploader({
  request: {
  endpoint: 'http://ahmdev.localhost/ajax/8pZ1zUUNKSfJftDT8h4zj4N7MpM1xYFcm862v5jfN9I/j3TFxihQ_8PpzIechgJ9_4ktPantebOjOt-pYFBXNtg'
  },
  callbacks: {
    onSubmit: function(id, fileName) {
      this.setParams({'test':'monkey'});
    }
  },
  debug: true,
  multiple: true,
  autoUpload: true,
  validation: {
    allowedExtensions: ['jpeg', 'jpg', 'txt'],
    sizeLimit: 10485760 // 10mb
  },
  retry: {
     enableAuto: true // defaults to false
  },
  text: {
     uploadButton: 'Click or Drop'
  },
  showMessage: function(message) {
  // Using Bootstrap's classes
    $('#restricted-fine-uploader').append('<div class="alert alert-error">' + message + '</div>');
  },
  deleteFile: {
    enabled: true, // defaults to false
    forceConfirm: true,
    endpoint: '/uploads'
  },
  paramsInBody : true,
  failedUploadTextDisplay: {
    mode: 'custom',
    maxChars: 40,
    responseProperty: 'error',
    enableTooltip: true
  }
});
}); 

我还试着用添加参数

params:{
            fileupload: 'test', 
            fileuploadname: 'monkey'
        }

但两者都未能奏效。

当端点运行时,我输出的第一件事是转储$_REQUEST、$_POST和$_GET的内容。结果中没有任何内容。

[FineUploader 3.7.0] responseText = <pre>array(2) {
["qquuid"]=>
string(36) "65aacd2f-2b09-4c37-96a1-ac706dba0a79"
["qqtotalfilesize"]=>
string(7) "2912372"
}
</pre><pre>array(2) {
 ["qquuid"]=>
string(36) "65aacd2f-2b09-4c37-96a1-ac706dba0a79"
["qqtotalfilesize"]=>
string(7) "2912372"
}
</pre><pre>array(0) {
}
</pre>

为什么我没有得到参数。我一辈子都想不出来。

print_r($_FILES)

Array
(
 [qqfile] => Array
    (
        [name] => IMG_0911.JPG
        [type] => image/jpeg
        [tmp_name] => C:'Windows'Temp'php7040.tmp
        [error] => 0
        [size] => 3509155
    )
)

对于初学者来说,您没有正确地声明您的选项。根据文档,params属性属于请求选项。

正确的做法是:

$('#fine-uploader-house').fineUploader({
  request: {
   endpoint: 'http://ahmdev.localhost/ajax/8pZ1zUUNKSfJftDT8h4zj4N7MpM1xYFcm862v5jfN9I/j3TFxihQ_8PpzIechgJ9_4ktPantebOjOt-pYFBXNtg',
   setParams(Object params, [optional] Integer fileId) // see link below
  },
  callbacks: {
    onSubmit: function(id, fileName) {
    }
  },

还有一种略有不同的方法,请参阅http://blog.fineuploader.com/2012/12/05/include-params-in-the-request-body-or-the-query-string/