UploadFile1.jsp
上传用户:mingda
上传日期:2017-06-20
资源大小:27691k
文件大小:3k
源码类别:

OA系统

开发平台:

Java

  1. <%@ page contentType="text/html; charset=GB2312" import="java.sql.*" import="java.lang.*" %>
  2. <%@ page import="java.io.*"%>
  3. <%@ page import="com.gforce.currency.clsupload.*"%>
  4. <html>
  5. <head>
  6. <title>文件上传</title>
  7. <SCRIPT LANGUAGE="JavaScript">
  8.     function AddVar()
  9.     {
  10.         frmadd.CheckButton.value="ADD";
  11.         var Nfile;
  12.         if (frmadd.filea.value=="")
  13.         {
  14.             alert("请先选择文件,然后再上传!");
  15.         }
  16.         else
  17.         {
  18.             frmadd.CheckButton.value="ADD";
  19.             frmadd.add.disabled=true;
  20.             frmadd.ok.disabled=true;
  21.             frmadd.submit();
  22.         }
  23.     }
  24.     function finishVar()
  25.     {
  26.         window.top.returnValue="";
  27.         window.top.close();
  28.     }
  29. //-->
  30. </SCRIPT>
  31. </head>
  32. <%
  33.     String destPathName = "/uploadfiles";
  34.     String fileName="";
  35.     if (request.getContentLength()>0)
  36.     {
  37.         ClsUpload upload=new ClsUpload(pageContext);
  38.         if (upload.getValue("CheckButton").equals("ADD"))
  39.         {
  40.             fileName=upload.fileAdd("filea", destPathName);
  41.             //fileName=new String(fileName.getBytes(), "ISO8859-1");
  42.             //String fileExpandName = fileName.substring(fileName.lastIndexOf(".")+1);
  43.             out.println("<script language="javascript">alert("上传成功!");window.top.returnValue=""+ fileName + "";window.top.close();</script>");
  44.         }
  45.     }
  46. %>
  47. <body leftmargin="0" topmargin="0">
  48. <table border="0" cellpadding="0" cellspacing="0" align="center" style="border:1px #6595D6 solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px;width:100%;">
  49.   <tr>
  50.     <td height="25" align="center" bgcolor="#6595D6"><font color="#0A0A0A" style="font-family: 宋体; font-size: 12px; line-height: 15px"><b>文件上传</b></font></td>
  51.   </tr>
  52.   <tr>
  53.     <td>
  54.       <form name="frmadd" method="post" enctype="multipart/form-data" action="">
  55.         <table width="100%" align="center">
  56.           <tr>
  57.             <td align="left" valign="top"><font size="2">1、请点“<font color=red>浏览</font>”选择要上传的文件</font>
  58.             </td>
  59.           </tr>
  60.           <tr>
  61.             <td align="left" valign="top"> <input name="filea" type="file" size="28" onKeyDown="return false;">
  62.             </td>
  63.           </tr>
  64.           <tr>
  65.             <td align="left"><font size="2">2、点“<font color="#ff0000">上传</font>”按钮上传文件
  66.               </font> <input type="submit" value="上传" name="add" onClick="javascript:AddVar()">
  67.               <input type="button" name="ok" value="取消"  onClick="javascript:finishVar()">
  68.               <input type="hidden" name="CheckButton">
  69.             </td>
  70.           </tr>
  71.         </table>
  72.       </form>
  73.     </td>
  74.   </tr>
  75. </table>
  76. </body>
  77. </html>