var files=[];var errors=[]; var chunk=<%=request.getParameter("chunk")%>; var root="",xml=""; var max_file_size='20MB'; var image='<%=request.getParam ...
var files=[];var errors=[];
var chunk=<%=request.getParameter("chunk")%>;
var root="",xml="";
var max_file_size='20MB';
var image='<%=request.getParameter("image")%>';
var id='<%=request.getParameter("id")%>';
var flag='<%=request.getParameter("flag")%>';
var conDir='<%=request.getParameter("conDir")%>';
var filters={title:"允許文件類型",extensions:"jpg,gif,png"};
$("#uploader").pluploadQueue($.extend({
runtimes:'flash',
url:'<%=path%>/uploaderxing?id='+id+'&flag='+flag+'&conDir='+conDir+'&image='+image,
max_file_size: max_file_size,
file_data_name:'file',
unique_names:true,
//在選擇的flash中只能選擇一個文件或圖片
multi_selection: false,
filters:[filters],
flash_swf_url:'<%=path%>/upload/plupload/plupload.flash.swf',
init:{
FileUploaded:function(uploader,file,response){
if(response.response){
var rs = $.parseJSON(response.response);
if(rs.status){
xml+='<name><![CDATA['+file.name+']]></name>';
xml+='<size>'+file.size+'</size>';
xml+='<newName>'+rs.newName+'</newName>';
xml+='<savePath>'+rs.savePath+'</savePath>';
files.push(xml);
}else{
errors.push(file.name);
}
}
},
//增加這個方法後就只能上傳一個文件 或者一個圖片
FilesAdded: function (uploader, files) {
$.each(uploader.files, function (i, file) {
if (uploader.files.length <= 1) {
return;
}
uploader.removeFile(file);
});
},
UploadComplete:function(uploader,fs){
window.parent.location.reload();
window.parent.reloadJQGrid();
target.window("close");
}
}
},
(chunk?{chunk_size:max_file_size}:{})));