Fine Uploader无法传递自定义参数

时间:2013-07-13 23:03:40

标签: php jquery fine-uploader

我已经在这里传达了几个小时并且无法让它发挥作用。 我对fineuploader的实现

$(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($ _文件)

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

)

1 个答案:

答案 0 :(得分:3)

对于初学者,您没有正确宣布您的选择。根据文档,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) {
    }
  },

Source

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