[size=large]上网上查了一些uploadify的用法,基本上都是上传到当前文件的相对目录下,指定filepath目录,但如果想在前台获取目录,在后台操作,将文件上传到非本地的目录(如服务器)时,要如何将目录传给后台呢?[/size]
$("#uploadify").uploadify({
'uploader': 'uploadify.swf',
'script':'servlet/Upload',
'cancelImg': 'images/cancel.png',
'queueID' : 'fileQueue',
'auto' : false,
'method': 'GET',
'multi': true,
'buttonText': 'BROWSE',
'simUploadLimit' : 1,
'sizeLimit': 19871202, //设置单个文件大小限制,单位为byte
'queueSizeLimit' : 20,
onSelect: function(event, queueID, fileObj) {
$("#uploadify").uploadifySettings("scriptData", { "path": encodeURI(encodeURI(document.getElementById("recDir").innerHTML)), "type": "test" }); //通过onSelect,将recDir的ID中的值传给后台,后台通过request.getParameter("path")获取。注意:这里为了得到中文的路径,后台需要将path数据decode一次。前台encode两次,后台解一次。
},
onComplete: function (event, queueID, fileObj, response, data) {
alert("文件:" + fileObj.name + "上传成功");
},
onError: function(event, queueID, fileObj) {
},
onCancel: function(event, queueID, fileObj){
alert("取消了" + fileObj.name);
}
});