[英]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.