在 javascript/jQuery 中,在调用文件上传插件之前,会设置一个变量:
doc_type = "q";
然后,插件被初始化。在插件选项中是:onSelect:
,在选择文件时调用。代码如下所示:
var doc_type = "q";
$(function(){
var project_num = $("#pnum").val();
var uploadObj = $("#fileuploader").uploadFile({
url: "upload_files_processor.php",
method: "POST",
onSelect: function(){
doc_type = "W";
//Or:
//doc_type = $('#hidden_input').val(); <-- What I really need to do
return true;
},
allowedTypes:"pdf,doc,docx,xls,xlsx,ppt,pptx,bmp,jpg,png,zip",
fileName: "myfile",
formData: {"project_num":project_num,"doc_type":doc_type},
multiple: true,
autoSubmit: true,
showStatusAfterSuccess:false,
onSuccess:function(files,data,xhr) {
//Refresh documents table
},
});
}); //END document.ready()
问题:
在上传处理器upload_files_processor.php
中,接收到的doc_type
值为:
$doc_type = $_POST["doc_type"]; // q
我怎样才能收到价值W
?
参考:heyageek jquery 上传文件插件网站--点击API & Options
tab