⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 upload.jsp

📁 一个不错的bbs论坛系统.对初学者很有帮助
💻 JSP
字号:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="comm/taglibs.jsp"%>
<html:html>
<head>
<title>上传附件</title>
<script language="JavaScript">
  var vbDOMtype = '';
  if (document.getElementById) {
    vbDOMtype = "std";
  }
  else if (document.all) {
    vbDOMtype = "ie4";
  }
  else if (document.layers){
    vbDOMtype = "ns4";
  }
  var openner=window.opener==null?parent:window.opener;
  
  switch (vbDOMtype) {
    case "std":{
      var attachlist = openner.document.getElementById("attachList");
    }
    break;
    case "ie4": {
      var attachlist = openner.document.all["attachList"];
    }
  }
  
  function verify_upload(formobj) {
    var haveupload = false;
    for (var i=0; i < formobj.elements.length; i++) {
      var elm = formobj.elements[i];
      if (elm.type == 'file'){
        if (elm.value != ""){
          haveupload = true;
        }
      }
    }
    if (haveupload){
      toggle_display();
      formobj.submit();
      formobj.upload.disabled=true;
    } else {
      alert("Please select your file for upload.");
    }
    return false;
  }
  
  function toggle_display() {
    var obj=uploading;
    if (obj.style.display == "none") {
      obj.style.display = "";
    } else {
      obj.style.display = "none";
    }
  }
</script>
<%
   int curNum = Integer.parseInt(request.getAttribute("curNum").toString());
%>
</head>
<body>
<html:form action="/UpLoad.htm" enctype="multipart/form-data"  method="post" >
<input type="hidden" name="artId" value="<bean:write name="artId" />">
<input type="hidden" name="action" value="<bean:write name="action" />">
<table class="tab1" cellpadding=0 cellspacing=0 border=0 align=center width="80%">
 <tr class="tr_1"><td align=center colspan=2 class="tab_c" height="24px"><b>管理附件</b></td></tr>
 <tr class="tr_1"><td align=center colspan=2 height="24px"><b>你上传附件空间剩余:<bean:write name="fleave"/>&nbsp;K</b></td></tr>
 <logic:greaterThan name="fleave" value="0">
 <tr><td width=40% class="td_t"><center><font color="red"><html:errors /></font></center>
      <b>上传附件或图片</b><br>最大允许<B>1024K</B>
     </td>
     <td class="td_lt">
	 <%for(int i=0;i<curNum;i++) {%>
	 &nbsp;&nbsp;<input type="file" size=30 name="formFile<%=i%>"><br>
	 <%}%>&nbsp;
     <select>
     <option value=#>选择上传类型:</option>
     <option value=#>----------</option>
     <option value=gif>gif</option>
     <option value=jpg>jpg</option>
     <option value=png>png</option>
     <option value=bmp>bmp</option>
     <option value=bmp>swf</option>
     <option value=rar>rar</option>
     <option value=zip>zip</option>
     <option value=doc>doc</option>
     <option value=txt>txt</option>
    </select><br><br>
   </td></tr>
 <tr><td align=center colspan=2 class="td_t">
      <input type="button" name="upload" value="上传" onclick="verify_upload(this.form);" />
 </td></tr>
 <logic:lessThan name="curNum" value="6">
 <tr><td class="td_t"><b>当前上传附件:</b></td>
     <td class="td_lt">&nbsp;<div id="uploadlist"></div>
     <script language="JavaScript">
       var attachListStr="";
       var insertText="";
       <logic:iterate id="attment" indexId="ind" name="allattmts">
         insertText+= "<a href='DownFile.htm?fileName=<bean:write name='attment' property='filename' />'><bean:write name='attment' property='realname' /></a><a href='UpLoad.htm?aId=<bean:write name="artId" />&faction=delete&fId=<bean:write name='attment' property='id'/>&filePath=<bean:write name='attment' property='path' />'>&nbsp;&nbsp;&nbsp;删除</a><br> ";
         attachListStr+= "<a href='DownFile.htm?fileName=<bean:write name='attment' property='filename' />'> "+
         	"<bean:write name='attment' property='realname' /></a> <a href=javascript:insertAtt('<bean:write name='attment' property='path' />','<bean:write name='attment' property='realname'/>','<bean:write name='attment' property='filetype'/>')>&nbsp;&nbsp;&nbsp;插入</a><br>";
       </logic:iterate>
       uploadlist.innerHTML = ""+insertText;
       opener.attachList.innerHTML = ""+attachListStr;
     </script>
     </td>
  </tr>
 </logic:lessThan>
 <logic:lessThan name="curNum" value="0">
   <script>opener.attachList.innerHTML='';</script>
 </logic:lessThan>
 <tr id="uploading" style="display:none;"><td align=center colspan=2><strong>Uploading, please wait...</strong></td></tr>
 </logic:greaterThan>
 <tr><td align=center colspan=2 class="td_t"><input type="button" value="关闭" onclick="window.close();" /></td></tr>
</table>
</html:form>
</body>
</html:html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -