dhtmlXVaultObject = function()
{
this.isUploadFile = "false";
this.isUploadFileAll = "false";
this.countRows = null;
this.idRowSelected = null;
this.sessionId = null;
//server handlers
this.pathUploadHandler = null;
this.pathGetInfoHandler = null;
this.pathGetIdHandler = null;
//demo
this.isDemo = true;
this.progressDemo = null;
//from PHP
this.MAX_FILE_SIZE = null;
this.UPLOAD_IDENTIFIER = null;
}
dhtmlXVaultObject.prototype.setServerHandlers = function(uploadHandler, getInfoHandler, getIdHandler)
{
this.pathUploadHandler = uploadHandler;
this.pathGetInfoHandler = getInfoHandler;
this.pathGetIdHandler = getIdHandler;
}
dhtmlXVaultObject.prototype.create = function(htmlObject)
{
this.parentObject = document.getElementById(htmlObject);
this.parentObject.style.position = "relative";
this.parentObject.innerHTML = "<iframe src='about:blank' id='dhtmlxVaultUploadFrame' name='dhtmlxVaultUploadFrame' style='display:none'></iframe>";
this.containerDiv = document.createElement("div");
this.containerDiv.style.cssText = "position:absolute;overflow-y:auto;height:190px;background-color:#FFFFFF;border:1px solid #878E95;top:10px;left:10px;z-index:10;width:410px";
this.parentObject.appendChild(this.containerDiv);
this.container = document.createElement("div");
this.container.style.position = "relative";
var str = "<table style='background-color:#EDEEEF;border: 1px solid #7A7C80;' border='0'>" +
"<tr><td style='width:420px' colspan=3 align='center' id = 'cellContainer' >" +
"<div style='height:200px;'></div>" +
"</td></tr>" +
"<tr><td style='width: 80px; height: 32px;' align='left'></td>" +
"<td style='width: 200px; height: 32px;' align='left'>" +
"<img _onclick='UploadControl.prototype.uploadAllItems()' _ID='ImageButton3' src='imgs/btn_upload.gif' style='cursor:pointer'/></td>" +
"<td style='width: 140px; height: 32px;' align='right'>" +
"<img _onclick='return UploadControl.prototype.removeAllItems()' _ID='ImageButton3' src='imgs/btn_clean.gif' style='cursor:pointer;margin-right:20px'/></td></tr></table>" +
"<div _id='fileContainer' style='width:84px;overflow:hidden;height:32px;left:0px;direction:rtl;position:absolute;top:211px'>" +
"<img style='z-index:2' src='imgs/btn_add.gif'/>" +
"<input type='file' id='file1' name='file1' value='' class='hidden' style='cursor:pointer;z-index:3;left:7px;position:absolute;height:25px;top:0px'/></div>";
this.container.innerHTML = str;
var self = this;
this.container.childNodes[0].rows[1].cells[1].childNodes[0].onclick = function() {
self.uploadAllItems()
};
this.container.childNodes[0].rows[1].cells[2].childNodes[0].onclick = function() {
self.removeAllItems()
};
this.fileContainer = this.container.childNodes[1];
this.fileContainer.childNodes[1].onchange = function() {
self.addFile()
};
this.uploadForm = document.createElement("form");
this.uploadForm.method = "post";
this.uploadForm.encoding = "multipart/form-data";
this.uploadForm.target = "dhtmlxVaultUploadFrame";
this.container.appendChild(this.uploadForm);
//from PHP
this.MAX_FILE_SIZE = document.createElement("input");
this.MAX_FILE_SIZE.type = "hidden";
this.MAX_FILE_SIZE.name = "MAX_FILE_SIZE";
this.MAX_FILE_SIZE.value = '200000000';
this.uploadForm.appendChild(this.MAX_FILE_SIZE);
this.UPLOAD_IDENTIFIER = document.createElement("input");
this.UPLOAD_IDENTIFIER.type = "hidden";
this.UPLOAD_IDENTIFIER.name = "UPLOAD_IDENTIFIER";
this.uploadForm.appendChild(this.UPLOAD_IDENTIFIER);
this.parentObject.appendChild(this.container);
this.tblListFiles = null;
this.currentFile = this.fileContainer.childNodes[1];
//if demo
if (this.isDemo)
{
this.progressDemo = this.createProgressDemo();
}
}
dhtmlXVaultObject.prototype.createXMLHttpRequest = function()
{
var xmlHttp = null;
if (window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
return xmlHttp
}
//get file name
dhtmlXVaultObject.prototype.getFileName = function(path)
{
var arr = path.split("\\");
return arr[arr.length - 1];
}
dhtmlXVaultObject.prototype.selectItemInExplorer = function(currentId)
{
var currentRow = this.getCurrentRowListFiles(currentId);
if (this.idRowSelected)
{
var row = this.getCurrentRowListFiles(this.idRowSelected);
if (row)
{
if (row.id != currentRow.id)
{
currentRow.style.background = "#F3F3F3";
this.idRowSelected = currentId;
row.style.background = "#FFFFFF";
}
else
{
currentRow.style.background = "#FFFFFF";
this.idRowSelected = "";
}
}
else
{
currentRow.style.background = "#F3F3F3";
this.idRowSelected = currentId;
}
} else
{
currentRow.style.background = "#F3F3F3";
this.idRowSelected = currentId;
}
}
dhtmlXVaultObject.prototype.selectItemInMozilla = function(currentId)
{
var currentRow = this.getCurrentRowListFiles(currentId);
if (this.idRowSelected)
{
var row = this.getCurrentRowListFiles(this.idRowSelected);
if (row)
{
if (row.id != currentRow.id)
{
currentRow.style.background = "#F3F3F3";
this.idRowSelected = currentId;
row.style.background = "#FFFFFF";
}
else
{
currentRow.style.background = "#FFFFFF";
this.idRowSelected = "";
}
}
else
{
currentRow.style.background = "#F3F3F3";
this.idRowSelected = currentId;
}
} else
{
currentRow.style.background = "#F3F3F3";
this.idRowSelected = currentId;
}
}
// add item in "upload control"
dhtmlXVaultObject.prototype.addFile = function()
{
var currentId = this.createId();
var file = this.currentFile;
file.disabled = true;
file.style.display = "none";
this.uploadForm.appendChild(file);
var newInputFile = document.createElement("input");
newInputFile.type = "file";
newInputFile.className = "hidden";
newInputFile.style.cssText = "cursor:pointer;z-index:3;left:7px;position:absolute;height:30px";
newInputFile.id = "file" + (currentId + 1);
newInputFile.name = "file" + (currentId + 1);
this.currentFile = newInputFile;
var self = this;
newInputFile.onchange = function() {
return self.addFile()
};
this.fileContainer.appendChild(newInputFile);
var fileName = this.getFileName(file.value);
var imgFile = this.getImgFile(fileName);
//create table ListFiles
var containerData = this.containerDiv;
if (this.tblListFiles == null)
{
this.tblListFiles = this.createTblListFiles();
containerData.appendChild(this.tblListFiles);
}
var rowListFiles = this.tblListFiles.insertRow(this.tblListFiles.rows.length);
rowListFiles.setAttribute("fileItemId", currentId);
rowListFiles.setAttribute("id", "rowListFiles" + currentId);
rowListFiles.setAttribute("isUpload", "false");
if (navigator.appName.indexOf("Explorer") != -1)
{
rowListFiles.onclick = function() {
self.selectItemIn
没有合适的资源?快使用搜索试试~ 我知道了~
JSP批量上传,实现多文件无刷新上传(带有进度条)。
共26个文件
gif:7个
png:5个
jsp:4个
5星 · 超过95%的资源 需积分: 49 327 下载量 49 浏览量
2008-12-21
13:44:49
上传
评论 6
收藏 109KB RAR 举报
温馨提示
JSP批量上传,实现多文件无刷新上传(带有进度条)。 程序加了些须的验证,目前只能上传图片。 压缩文件为Eclipse项目文件,直接导入即可使用 预览图片地址: http://i.namipan.com/files/9a3d11c4cb4fd230660565481eb1072e2b8b3861795900008cb8/3/1.jpg 注:所有文件保存到项目文件夹下的uplaod文件夹下,如果uplaod不存在,程序将自动创建uplaod文件夹。
资源推荐
资源详情
资源评论
收起资源包目录
test.rar (26个子文件)
test
.project 1KB
.mymetadata 285B
WebRoot
css
dhtmlXVault.css 715B
WEB-INF
web.xml 375B
lib
commons-fileupload-1.1.jar 31KB
fileupload-progress.jar 5KB
commons-io-1.1.jar 60KB
index.jsp 2KB
META-INF
MANIFEST.MF 39B
imgs
th_dhtmlxvault.gif 3KB
btn_upload.gif 1KB
pb_back.gif 289B
ico_zip.png 1KB
pb_demoUload.gif 5KB
ico_video.png 2KB
ico_image.png 1KB
ico_sound.png 2KB
btn_clean.gif 1KB
ico_file.png 1KB
pb_empty.gif 44B
btn_add.gif 1KB
GetIdHandler.jsp 364B
UploadHandler.jsp 2KB
GetInfoHandler.jsp 124B
js
dhtmlXVault.js 22KB
.classpath 584B
共 26 条
- 1
fhygogo
- 粉丝: 2
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页