81,122
社区成员




function submit_upload(){
if(isAttNum()) return false;
var file_name = document.all.FILE1.value;
try{
var len = file_name.length;
var ixg = 0;
var fileName = "";
if(file_name.indexOf("\\")!=-1)
ixg = file_name.lastIndexOf("\\");
else
ixg = file_name.lastIndexOf("/");
fileName = file_name.substr(ixg+1);
for (var i=0; i<document.all.item('fileList').options.length;i++){
var f_name = document.all.item('fileList').options(i).text;
if(fileName==f_name){
alert("该附件已经上传,请选择其他附件!");
return;
}
}
if(file_name.indexOf("<")>=0 || file_name.indexOf(">")>=0 || file_name.indexOf("#")>=0 ||
file_name.indexOf("&")>=0 || file_name.indexOf(";")>=0 || file_name.indexOf("+")>=0 ||
file_name.indexOf(",")>=0 || file_name.indexOf("\'")>=0 || file_name.indexOf("\"")>=0 ){
alert('请不要上传带“<、>、#、&、;、+、,、\'、\"”名字的文件,可以输入全角的,请修改名字再上传!');
}else if(file_name.indexOf(" ")>=0){
alert("上传的附件名不能包含两个或两个以上相邻的空格字符!");
}else if(file_name.indexOf("正式文件.doc")!=-1 ){
alert("上传的附件中不能包含“正式文件.doc”关键字样!");
}else if(len-ixg>100){
alert("上传的附件名字太长!");
}else{
document.form1.submit();
}
}catch(e){}
}
function funUploadFile(strAtt1,strAttInfo1){
var strAtt;
var strfile ;
try {
if (strAtt1=="null" || strAtt1=="") {
strAtt = window.opener.document.getElementById(attInfo).value;
if (strAtt!=null && strAtt!="") {
while(strAtt.indexOf("@")>0) {
strfile = strAtt.substring(0,strAtt.indexOf("@"));
if (strAtt.indexOf("\\")!=-1) {
strfileText = strfile.substring(strfile.lastIndexOf("\\")+1,strfile.length);
} else {
strfileText = strfile.substring(strfile.lastIndexOf("/")+1,strfile.length);
}
var optionTmp =document.createElement('OPTION');
optionTmp.text=strfileText;
optionTmp.value=strfile;
document.all.fileList.options.add(optionTmp);
strAtt = strAtt.substring(strAtt.indexOf("@")+1, strAtt.length);
}
document.all.allFile.value=window.opener.document.getElementById(attInfo).value;
}
}
if(strAttInfo1 == null || strAttInfo1 == "" || strAttInfo1 == "null"){
document.getElementById("myFileInfo").value=window.opener.document.getElementById(attInfoDetail).value;
}
} catch(e) {}
document.all.uploadFileHead.value = window.opener.document.all.uploadFileHead.value.replace(new RegExp("\\\\","gm"),"/");
document.all.uploadFileAdd.value = window.opener.document.all.uploadFileAdd.value.replace(new RegExp("\\\\","gm"),"/") + attdiv + "/<%=Time %>";
// servlet传回来的值
if (strAtt1!="null") {
while(strAtt1.indexOf("@")>0) {
strfile = strAtt1.substring(0,strAtt1.indexOf("@"));
strfileText = strfile.substring(strfile.lastIndexOf("/")+1,strfile.length)
var optionTmp =document.createElement('OPTION');
optionTmp.text=strfileText;
optionTmp.value=strfile;
document.all.fileList.options.add(optionTmp);
strAtt1 = strAtt1.substring (strAtt1.indexOf("@")+1,strAtt1.length);
}
document.all.allFile.value="<%=request.getParameter("attachment")%>";
}
if(strAttInfo1!=null && strAttInfo1!=""){
var myFileInfo = document.getElementById("myFileInfo").value;
document.getElementById("myFileInfo").value = myFileInfo + "#" +strAttInfo1;
}
if(document.all.fileList.options.length>0){
document.getElementById("btnup").disabled='false';
}else{
document.getElementById("btnup").removeAttribute("disabled");
}
}
function delSelected(tbox) {
var i,j=0,c;
var tLength = tbox.options.length;
var arrTbox = new Array();
var arrLookup = new Array();
for (i=0; i<tLength; i++) {
if(tbox.options[i].selected == false){
arrLookup[tbox.options[i].text] = tbox.options[i].value;
arrTbox[j] = tbox.options[i].text;
j++;
}
}
tbox.length=0;
for(c=0; c<arrTbox.length; c++){
var no = new Option();
no.value = arrLookup[arrTbox[c]];
no.text = arrTbox[c];
tbox[c] = no;
}
document.all.allFile.value = "";
var HTTPDOWNLOAD=document.all.HTTPDOWNLOAD.value;
for(k=0;k<tbox.options.length;k++){
if (document.all.allFile.value != ""){
document.all.allFile.value += "@"+tbox.options[k].value;
}else{
document.all.allFile.value += tbox.options[k].value;
}
}
var fileAdd="";
var strInerHtml ="";
var stratt ="";
for (var i = 0; i< document.all.item('fileList').options.length;i++){
var optionTmp = window.opener.document.createElement('OPTION');
var fileText = document.all.item('fileList').options(i).text;
fileText = fileText.substring(fileText.lastIndexOf("\\")+1);
optionTmp.text=fileText;
var test = document.all.item('fileList').options(i).value;
stratt += test+"@";
while (test.lastIndexOf("\\")!=-1) {
test = test.replace("\\","\/");
}
optionTmp.value=document.all.item('fileList').options(i).value;
// window.opener.document.all.attachments.options.add(optionTmp);
// window.opener.document.all.attachments.options[i].selected="true";
strInerHtml+=(i+1)+".<A href=\"javascript:downPopUp('"+test+"');\">"+fileText+"</A> ";
//strInerHtml+=(i+1)+".<A href=\"../upload/openfile.jsp?path="+HTTPDOWNLOAD+test+"\" target=_blank>"+fileText+"</A> ";
}
//for(var i = 0; i< window.opener.document.all.item('attachments').options.length;i++){
// window.opener.document.all.attachments.options[i].selected="true";
//}
if(document.all.fileList.options.length<=0){
document.getElementById("btnup").removeAttribute("disabled");
}
window.opener.document.getElementById(attdiv).innerHTML=strInerHtml;
window.opener.document.getElementById(attInfo).value=stratt;
try{window.opener.document.all.faMaterial.value=stratt;}catch(e){}
}
function submitUpload(){
if(document.all.allFile.value=="") {
alert("您没有上传附件!");
return false;
}else{
var fileAdd="";
var strInerHtml ="";
var stratt ="";
var HTTPDOWNLOAD=document.all.HTTPDOWNLOAD.value;
for (var i = 0; i< document.all.item('fileList').options.length;i++){
var optionTmp = window.opener.document.createElement('OPTION');
var fileText = document.all.item('fileList').options(i).text;
fileText = fileText.substring(fileText.lastIndexOf("\\")+1);
optionTmp.text=fileText;
var test =document.all.item('fileList').options(i).value;
stratt+=test+"@";
while (test.lastIndexOf("\\")!=-1) {
test = test.replace("\\","\/");
}
optionTmp.value=document.all.item('fileList').options(i).value;
//window.opener.document.all.attachments.options.add(optionTmp);
//window.opener.document.all.attachments.options[i].selected="true";
strInerHtml+="<A href=\"javascript:downPopUp('"+test+"');\">"+fileText+"</A> ";
//if (fileText!="")
//strInerHtml+=(i+1)+".<A href=\"../upload/openfile.jsp?path="+HTTPDOWNLOAD+test+"\" >"+fileText+"</A> ";
}
//for(var i = 0; i< window.opener.document.all.item('attachments').options.length;i++){
// window.opener.document.all.attachments.options[i].selected="true";
//}
try{
window.opener.document.getElementById(attdiv).innerHTML=strInerHtml;
window.opener.document.getElementById(attInfo).value=stratt;
window.opener.document.getElementById(attInfoDetail).value = document.getElementById("myFileInfo").value;
//try{window.opener.document.all.faMaterial.value=stratt;}catch(e){}
//try{window.opener.document.all.materialAttach.value=stratt;}catch(e){}
try{
if('<%=attNum%>'=='true') window.opener.document.getElementById(attdiv).innerHTML= " "+strInerHtml.substring(2);
//window.opener.document.all.materialAttach.value=stratt;
//var result = document.all.item('fileList').options(0).text;
//if(result.indexOf(".")!=-1)result = result.substring(0,result.indexOf("."));
//window.opener.document.all.materialName.value=result;
}catch(e){}
}catch(e){}
window.close();
}
}
</script>
</BODY>
</HTML>
<%@ page contentType="text/html;charset=UTF-8"%>
<%
//String httpUrl = com.talkweb.ei.common.CommonConfig.getInstance().getFileServerHttpDir();
//System.out.println(httpUrl);
boolean attNum = ("1").equals(request.getParameter("attNum"));
String attDiv = request.getParameter("attDiv");
String attInfo = request.getParameter("attInfo");
String attInfoDetail = request.getParameter("attInfoDetail");
attDiv = attDiv==null || attDiv.trim().length()==0 ? "attCreateWord" : attDiv.trim();
attInfo = attInfo==null || attInfo.trim().length()==0 ? "attachment" : attInfo.trim();
attInfoDetail = attInfoDetail==null || attInfoDetail.trim().length()==0 ? "attachmentDetail" : attInfoDetail.trim();
String Time = new java.text.SimpleDateFormat("yyyyMMddhhmmss").format(java.util.Calendar.getInstance().getTime());
%>
<HTML>
<HEAD>
<title>文件上传</title>
<LINK href="../../css/style.css" type="text/css" rel="stylesheet" />
</HEAD>
<body bgColor="#f2f2f2" leftMargin="0" topMargin="0">
<FORM name=form1 METHOD="POST" ACTION="../../servlet/FileUploadServlet" target="hidden_frame" encType="multipart/form-data">
<TABLE cellspacing="0" cellpadding="0" width="100%" border="0">
<!--
<TR>
<TD>
<img height="50" src="../../images/win1.jpg" width="12">
</TD>
<TD width="3%" background="../../images/winbg.jpg">
<img height="50" src="../../images/win2.jpg" width="27">
</TD>
<TD width="94%" background="../../images/winbg.jpg">
<img height="50" src="../../images/fjsc.jpg" width="100">
</TD>
<TD class="style2" align="right" width="1%"
background="../../images/winbg.jpg">
<img height="50" src="../../images/win4.jpg" width="1">
</TD>
<TD align="left" width="1%">
<img height="50" src="../../images/win3.jpg" width="9">
</TD>
</TR>
-->
<TR>
<TD width="1%"> </TD>
<TD colspan="3">
<TABLE height="100%" cellspacing="0" cellpadding="0" width="100%"
border="0">
<TR>
<TD valign="top" width="1%" bgcolor="#f1f1f1">
<TABLE height="100%" cellspacing="0" cellpadding="0" width="1"
bgcolor="#0e4e96" border="0">
<TR>
<TD width="1"></TD>
</TR>
</TABLE>
</TD>
<TD align="center" width="97%" bgcolor="#f1f1f1">
<TABLE id="Table1" cellspacing="1" cellpadding="1" width="98%"
align="center" bgcolor="#f2f2f2" border="0">
<TR id="trDisplay1">
<TD class="tr3" width="20%">
文 件:
</TD>
<TD>
<input type="FILE" name="FILE1" size="25">
<input id="btnup" type="button" value="上传" onclick="submit_upload();myupload(0)">
</TD>
</TR>
<TR id="trDisplay3" height="45">
<TD class="tr3">
附件列表:
</TD>
<TD>
<SPAN id="Label1" class="tr3" style="display:block"><FONT color="red">
*选中列表框中文件名,点击删除,则此文档不上传。<br> *点击确定后,不能再次上传;点击关闭后,能再次上传。
</FONT>
</SPAN>
</TD>
</TR>
<TR>
<TD class="ourfont1"><FONT face="宋体"></FONT></TD>
<TD align="left">
<select style="WIDTH: 80%" multiple="multiple" size="5" name=fileList></select>
</TD>
</TR>
<TR>
<TD align="center" colspan="2">
<input type="button" name="uploadFile" value="确定" id="BtSave" class="but50" onclick="submitUpload();myconfirm();">
<input type="button" name="button2" value="删除" id="button2" class="but50" onclick="delMyFileInfo();delSelected(this.form.fileList);">
<input type="button" name="Button3" value="关闭" id="Button3" class="but50" onClick="javascript:window.close();" />
<input type="hidden" name="HTTPDOWNLOAD" width=0 value=''>
<input width=0 type="hidden" name="uploadFileHead" value="">
<input width=0 type="hidden" name="uploadFileAdd" value="">
<input width=0 type="hidden" name="allFile" value="">
<input type="hidden" id="myFileInfo" value="">
</TD>
</TR>
</TABLE>
<BR>
</TD>
<TD valign="top" align="right" width="1%" bgcolor="#f1f1f1">
<TABLE height="100%" cellspacing="0" cellpadding="0" width="1"
bgcolor="#0e4e96" border="0">
<TR>
<TD width="1"></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR bgcolor="#0e4e96">
<TD colspan="3" height="1"></TD>
</TR>
</TABLE>
</TD>
<TD></TD>
</TR>
</TABLE>
</FORM>
<iframe name='hidden_frame' id="hidden_frame" style='display:none'></iframe>
<script>
var attdiv = "<%=attDiv %>";
var attInfo = "<%=attInfo %>";
var attInfoDetail = "<%=attInfoDetail%>";
window.onload =function (){funUploadFile('','');};
function myalert(msg){
window.alert(msg);
}
function myupload(i){
if(i==0){
document.getElementById('Label2').style.display="block";
document.getElementById('Label1').style.display="none";
}
if(i==1){
document.getElementById('Label1').style.display="block";
document.getElementById('Label2').style.display="none";
}
}
function myconfirm(){
opener.document.getElementById('lnkupload').style.display="none";
}
function delMyFileInfo(){
var filedir = document.all.item('fileList').value;
var myFileInfo = document.getElementById("myFileInfo").value;
if(filedir!=null&&filedir!=""&&myFileInfo!=null&&myFileInfo!=""){
var files = myFileInfo.split("#");
myFileInfo = "";
for(var i=0;i<files.length;i++){
var file = files[i];
if(file==null||file==""){
continue;
}
var infos = file.split("@");
var url = infos[1];
if(url!=filedir){
myFileInfo = myFileInfo+"#"+file;
}
}
document.getElementById("myFileInfo").value = myFileInfo;
window.opener.document.getElementById(attInfoDetail).value = myFileInfo;
}
}
function isAttNum(){
var attNum = '<%=attNum%>';
if(attNum=='true'&&document.all.item('fileList').options.length>0) {
alert("一次只允许添加一个附件!");
return true;
} else {
return false;
}
}
function submit_upload(){
if(isAttNum()) return false;
var file_name = document.all.FILE1.value;
try{
var len = file_name.length;
var ixg = 0;
var fileName = "";
if(file_name.indexOf("\\")!=-1)
ixg = file_name.lastIndexOf("\\");
else
ixg = file_name.lastIndexOf("/");
fileName = file_name.substr(ixg+1);
for (var i=0; i<document.all.item('fileList').options.length;i++){
var f_name = document.all.item('fileList').options(i).text;
if(fileName==f_name){
alert("该附件已经上传,请选择其他附件!");
return;
}
}
if(file_name.indexOf("<")>=0 || file_name.indexOf(">")>=0 || file_name.indexOf("#")>=0 ||
file_name.indexOf("&")>=0 || file_name.indexOf(";")>=0 || file_name.indexOf("+")>=0 ||
file_name.indexOf(",")>=0 || file_name.indexOf("\'")>=0 || file_name.indexOf("\"")>=0 ){
alert('请不要上传带“<、>、#、&、;、+、,、\'、\"”名字的文件,可以输入全角的,请修改名字再上传!');
}else if(file_name.indexOf(" ")>=0){
alert("上传的附件名不能包含两个或两个以上相邻的空格字符!");
}else if(file_name.indexOf("正式文件.doc")!=-1 ){
alert("上传的附件中不能包含“正式文件.doc”关键字样!");
}else if(len-ixg>100){
alert("上传的附件名字太长!");
}else{
document.form1.submit();
}
}catch(e){}
}
<%@ page contentType="text/html;" pageEncoding="UTF-8"%>