需要一些帮助才能将上传文件大小变量传递给端点(php控制器)。我尝试了多种方法,但似乎方法不起作用。
首先,我无法获得getSize函数所必需的上传文件'id'。
其次,当我在参数:object中放入getSize函数时,系统会出错。我的代码的一部分如下:
var loader=$('#fine-uploader-s3').fineUploaderS3({
... ...
//deleted not relevant code above
uploadSuccess: {
endpoint: "/s3/uploadSuccessful",
customHeaders:
{'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
params: {
user_id:'{{Auth::user()->id}}', // there are params I want to
lot_id: '{{$lot->id}}', //pass to the controller
//no issue. the php controller
//got them. this code is part of
.. ... //Laravel blade.
size: function (){
return this.uploaderMethods.getSize('0');
//hard code file id 0 for test. not working.
或者我尝试过:size: function (){
return this.getSize('0');
或者size: $('#fine-uploader-s3').fineUploaderS3('getSize', '0'),
它们都不起作用。感谢您的帮助。
使用setUploadSuccessParams在文档中找到答案。添加一个回调块,如下所示:
callbacks: {
onSubmit: function (id, fileName) {
var size = this.getSize(id);
var newParams = {"size": size};
loader.setUploadSuccessParams(newParams, id)
}
},