1

我已经在这方面发了几个小时的消息,但无法让它发挥作用。我对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($_FILES)

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

)
4

1 回答 1

3

首先,您没有正确声明您的选项。根据文档, params 属性属于 request 选项。

正确的是:

$('#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/

于 2013-07-13T23:11:23.233 回答