📄 upload.jsp
字号:
<%@ page language="java" contentType="text/html;charset=UTF-8"%><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>上传文件 - 野蔷薇社区</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
body{background-color:#D4D0c8; font:12px "Verdana","宋体"; margin:0px 0px 5px 0px; padding:6px;}
*{margin:0px; padding:0px; list-style:none; color:black;}
table{font-size:12px;margin:4px;}
label{float:left; height:25px; line-height:25px; margin-left:4px; text-align:right; width:56px; font-weight: bold; color:#333333;}
.file { height:18pt; line-height:18pt;border-left:1px solid #D4D0C8; border-top:1px solid #D4D0C8; border-right:1px solid #999999; border-bottom:1px solid #999999; padding-top:4px 2px 2px 2px;}
.btn {border-left:1px solid #F6F6F6; border-top:1px solid #F6F6F6; border-right:1px solid #999999; border-bottom:1px solid #999999; height:18pt; background-color:#D4D0C8;padding: 3px 2px 0px 2px;}
.hide{display:none;}
.r{float:right; line-height:30px;}
a, a:link, a:visited{text-decoration:underline; cursor:pointer;}
.loading{border-top: 1pt solid #AAAAAA; border-right:1pt solid #f6f6f6; border-bottom:1pt solid #f6f6f6; border-left:1pt solid #AAAAAA; margin: 1pt 1pt 1pt;}
.loading2{border-top: 1pt solid #E6E6E6; border-left: 1pt solid #E6E6E6; margin: 1pt 1pt 1pt;}
-->
</style>
<script type="text/javascript" src="../scripts/common.js"></script>
<script type="text/javascript">
function FileUploadUtils(){
var dhttp; var iv; var err=false;
this.setSize = function(){
parent.c.o("fileupload").style.height=document.body.scrollHeight+"px";
parent.c.o("fileupload").style.width=document.body.scrollWidth+"px";
};
this.unupload = function(){
parent.c.o("content_hint_upload").parentNode.removeChild(parent.c.o("content_hint_upload"));
};
this.uploading = function(){
err = false;
var btn = c.o("qwSubmit");
btn.value="上传中...";
btn.disabled = true;
c.o("uploading").style.display = "block";
this.setSize();
this.httpGet();
this.interval();
};
this.interval = function(){
iv = setInterval("f.httpGet()",1000);
};
this.httpGet = function(){
var now = new Date();
myxmlhttp = CreateXmlHttpReq(this.xmlHttpHandler);
XmlHttpGET(myxmlhttp, "/club/fileUpload.do?r="+now.getTime());
};
this.initial = function(){
var now = new Date();
dhttp = CreateXmlHttpReq(this.initHttpHandler);
XmlHttpGET(myxmlhttp, "/club/fileUpload.do?act=inital&r="+now.getTime());
};
this.initHttpHandler = function(){
if (dhttp.readyState !=4 ) {
return;
}
var html = dhttp.responseText;
};
this.xmlHttpHandler = function(){
if (myxmlhttp.readyState !=4 ) {
return;
}
var html = myxmlhttp.responseText;
if(html!=undefined&&html.length>0){
f.progress(html);
}
};
this.progress = function(text){
var rs = text.parseJSON();
var fileSize = rs["fileSize"];
var readSize = rs["readSize"];
var fileExt = rs["fileExt"];
var url = rs["url"];
var originalFileName = rs["originalFileName"];
if(err){
clearInterval(iv);
return;
}
var rate = 0;
if(fileSize>0&&readSize>0){
rate = readSize/fileSize;
c.setHtml("readSize",readSize);
c.setHtml("fileSize",fileSize);
c.o("imgLoading").style.width = 300*rate;
if(rate==1){
this.setContent(url, fileExt, originalFileName);
url = "";
fileExt = "";
}
}
};
this.setContent = function(url, text, originalFileName){
if(url.length<=0){
//alert("发生意外错误,请重新上传!!!");
return ;
}
var html = "";
function img(url){
var t = "<img src=\""+url+"\"/>";
return t;
}
switch(text){
case "mp3":
html = "[video=300,80]"+url+"[/video]";
break;
case "wma":
html = "[video=300,80]"+url+"[/video]";
break;
case "mid":
html = "[video=300,80]"+url+"[/video]";
break;
case "wmv":
html = "[video=480,400]"+url+"[/video]";
break;
case "avi":
html = "[video=480,400]"+url+"[/video]";
break;
case "rm":
html = "[real=480,400]"+url+"[/real]";
break;
case "rmvb":
html = "[real=480,400]"+url+"[/real]";
break;
case "jpg":
html = img(url);
break;
case "jpeg":
html = img(url);
break;
case "png":
html = img(url);
break;
case "gif":
html = img(url);
break;
case "bmp":
html = img(url);
break;
default:
html = "<a href=\""+url+"\">"+originalFileName+"</a>";
}
html += "<br/>";
var text = parent.ed.getEditorContents()+html;
parent.ed.setEditorContents(text);
this.unupload();
this.initial();
window.clearInterval(iv);
};
this.error = function(txt){
err = true;
c.o("body").style.display = "none";
c.o("message").style.display = "block";
txt = txt + " <a onclick=\"f.back()\">点这儿返回上一步</a>";
c.setHtml("message",txt);
};
this.back = function(){
parent.dvo.reset(parent.c.o("content_cmd_upload"));
};
}
var f = new FileUploadUtils();
window.onload = function(){
f.setSize();
}
</script>
</head>
<body>
<div id="message" style="display:none"></div>
<div id="body">
<form name="fileup" id="fileup" method="POST" action="/club/fileUpload.do?forumId=<%=com.yeqiangwei.util.ParamUtils.getStringParameter(request,"forumId","0")%>" target="uploadpost" ENCTYPE="multipart/form-data" onsubmit="return f.uploading()">
<span class="r"><a onclick="javascript:f.unupload();">取消上传</a></span>
<input id="files" name="files[]" type="FILE" class="file">
<input name="qwSubmit" id="qwSubmit" type="submit" class="btn" value="上传">
</form>
</div>
<div class="hide" id="uploading">
<iframe name="uploadpost" id="uploadpost" frameborder="0" width="100%" height="0" scrolling="no" src="/club/fileUpload.do"></iframe>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2">
<tr><td><span style="float:right"><strong>当前读取</strong>:<span id="readSize"></span></span><strong>文件大小</strong>:<span id="fileSize"></span></td></tr>
<tr><td></td></tr>
</table>
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0" class="loading">
<tr><td height="18" class="loading2"><img src="../images/loadingImg.gif" width="0" height="18" id="imgLoading"></td></tr>
</table>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -