我已经为此发了几个小时的消息,但无法让它工作。 我对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>
为什么我没有获取到参数。我一生都无法弄清楚。
打印_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/
关于php - Fine Uploader 无法传递自定义参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17634970/