简体   繁体   English

Blueimp插件文件上传Jquery:向PHP处理程序发送其他信息

[英]Blueimp plugin fileupload Jquery: Send additional information to PHP handler

I'm trying to send information (additional Handling form data) from fileupload jquery plugin (blueimp) to PHP file. 我正在尝试从fileupload jquery插件(blueimp)向PHP文件发送信息(其他处理表单数据)。 In the PHP file handle can not get the information (content of variable). 在PHP文件句柄中无法获取信息(变量的内容)。 I think I have a problem in the code. 我认为代码中有问题。 Can some altruistic soul enlighten the way? 某些无私的灵魂能启发我们吗? Thanks in advance. 提前致谢。

Javascript file: Javascript文件:

$(function () {
$('#fileupload').fileupload({
    dataType: 'json',   
    formData: {idGrupo: 250},  <----I want to send this to PHP file!
    done: function (e, data) {
    $.each(data.result, function (index, file) {
       // $('<p/>').text(file.name).appendTo('body');
   });
}
});
});

PHP file (index.php ): PHP文件(index.php):

error_reporting(E_ALL | E_STRICT);
require('UploadHandler.php');

class CustomUploadHandler extends UploadHandler
{
    protected function handle_form_data($file, $index) {
        $sesionIdGrupo2 = $_REQUEST['idGrupo'];
}

    protected function trim_file_name($name, $type, $sesionIdGrupo2) {
        $name = parent::trim_file_name($name, $type);
        $name = $seionIdGrupo2;
        return $name;
}
}

$upload_handler = new CustomUploadHandler();

Again I appreciate the help, that would not do without this community (well yes, would do anything that was not code ;). 我再次感谢您的帮助,如果没有这个社区,这将是无济于事的(嗯,是的,它将做任何非代码的事情;)。 Please be patient, I am newbie :( 请耐心等待,我是新手:(

Note: The variable $sesionIdGrupo2 not retrieve the value. 注意:变量$ sesionIdGrupo2无法检索该值。 My intention is to put the contents of this variable (250) as the name of the uploaded file. 我的意图是将此变量(250)的内容作为上载文件的名称。 ¿Could it be a problem of global variables? ¿可能是全局变量的问题吗?

To send Data to PHP UploadHandler.php just send it via url like this: 要将数据发送到PHP UploadHandler.php,只需通过url发送,如下所示:

$(function () {
     $('#fileupload').fileupload({
          url: 'server/php/index.php?idGrupo=250',
          dataType: 'json',
          autoUpload: false,
     });
});

....i solve that problem! .... i解决了这个问题! ...i put the Request inside the function "trim_file_name". ...我将请求放入函数“ trim_file_name”中。 I think is bad idea, but seem work... 我认为这是个坏主意,但似乎可以解决...

protected function trim_file_name($name, $type) {
    $name = parent::trim_file_name($name, $type);
    $sesionIdGrupo = $_REQUEST['idGrupo']; <------this work, recibed 250
    $name = $sesionIdGrupo;
    return $name;

Saludos! 礼炮!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 隐藏(不删除)Blueimp jquery fileupload插件中的复选框 - Hide(not delete) the checkbox in Blueimp jquery fileupload plugin 如何重置 blueimp jQuery 文件上传插件? - how can I reset a blueimp jQuery fileupload plugin? 向Simple Jquery FileUpload添加其他信息 - Adding additional information to Simple Jquery FileUpload AJAX输入上的jQuery Fileupload Blueimp - jQuery Fileupload Blueimp on AJAX input Blueimp fileupload在提交时将json对象发送到控制器 - Blueimp fileupload send json object to controller on submit jQuery Blueimp fileupload插件删除文件而不需要先检查复选框? - jQuery Blueimp fileupload plugin delete files without requiring checking checkbox first? 带有AngularJS和Spring MVC的jQuery Fileupload(Blueimp) - jQuery Fileupload (Blueimp) with AngularJS and Spring MVC blueimp jquery文件上传错误.fileupload不是函数 - blueimp jquery file upload error .fileupload is not a function jQuery Blueimp FileUpload上的DELETE方法不允许使用Codeigniter / PHP(405错误)? - DELETE method on jQuery Blueimp FileUpload not allowed using Codeigniter/PHP (405 error)? 通过Jquery BlueImp文件上传插件传递的其他数据在服务器端无法正确获取 - Additional data passed via Jquery BlueImp File Upload Plugin not getting correctly at Server side
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM