`
zhoutiea
  • 浏览: 38142 次
  • 性别: Icon_minigender_1
  • 来自: 沈阳
社区版块
存档分类
最新评论

异步上传文件

    博客分类:
  • java
 
阅读更多

<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
     <title>XACTI呼叫系统客户添加页面</title>
     <link href="../all.css" rel="stylesheet" rev="stylesheet" type="text/css" media="all"/>
    <script type="text/javascript" src="Jscript/common.js"></script>
 </head>
  <body onLoad="putFaxNo();">
  <div style="width:99%;padding-left: 1px;">
  <div style="font-size: 12px; font-weight: bold;color:#426EB4;"><img src="../Image/cus.gif" style="margin-bottom: -3px;"/> &nbsp;发送传真</div>
  <br>
   <table class="tform">
   <tbody>
    <tr>
     <td>公司名称:
     <td colspan="4">
     <input type="text" id="fullNmae" name="fullName" class="cfb" style="width: 324px;" onMouseDown="this.className='cfb2'" onBlur="this.className='cfb'"/></td>
    </tr>
    <tr>
     <td width="60">
     传真号码: </td>
     <td>
     <input type="text" id="phoneNo" name="phoneNo" class="cfb" onMouseDown="this.className='cfb1'" onBlur="this.className='cfb'"/>
     </td>
     <td>拔通电话:</td>
     <td colspan="2"><img src="../img/ic2.gif" onclick="callClient();" style="cursor: hand;"/></td>
    </tr>
    <tr>
     <td>文件编码:</td>
     <td width="160">
     <input type="text" id="faxname" name="faxname" readonly="readonly"  class="cfb" onMouseDown="this.className='cfb1'" onBlur="this.className='cfb'"/>     </td>
     <td width="62">文件名称:</td>
     <td width="442" colspan="2">
      <input type="text" id="uploadname" name="uploadname" style="width: 100%;" class="cfb" onMouseDown="this.className='cfb1'" onBlur="this.className='cfb'"/>     </td>     
    </tr>
    <tr>
     <td>上传时间:</td>
     <td>
      <input type="text" id="uploadtime" name="uploadtime" readonly="readonly" class="cfb" onMouseDown="this.className='cfb1'" onBlur="this.className='cfb'"/>     </td>
     <td>打开浏览:     </td>
     <td colspan="2"><img src="../Image/down2.gif" onclick="openuploadfile();" style="margin-bottom: -3px;cursor: hand;"/>  </td>
       </tr>
    <tr>
     <td>文件大小:</td>
     <td>
     <input type="text" class="cfb" id="faxsize" name="faxsize" readonly="readonly" onMouseDown="this.className='cfb1'" onBlur="this.className='cfb'"/>     </td>
     <td> 发送人:     </td>
     <td colspan="2">
      <input type="text" class="cfb" id="workName" name="workName" readonly="readonly" /></td>
    
    </tr>
    <tr>
     <td>发送时间:</td>
     <td>
     <input type="text" class="cfb" id="sendtime" name="sendtime" readonly="readonly" onMouseDown="this.className='cfb1'" onBlur="this.className='cfb'"/>     </td>
     <td>发送状态: </td>
     <td colspan="2">
     <input type="text" class="cfb" id="sendstate" name="sendstate" readonly="readonly"/></td> 
    </tr>
    <tr>
     <html:form action="/AjaxUpload" styleId="uploadForm" target="upload_frame" method="post" enctype="multipart/form-data">
     <td>上传路径:</td>
     <td>
      <input name="fax1" type="file" id="fax1" style="width: 160px;" />
     </td>
     <td>开始上传:</td>
     <td><img src="../Image/up2.gif" style="margin-bottom: -3px; cursor: hand;" onclick="uploadprintfile();"/> </td>
     <td>上传状态:&nbsp;&nbsp;<span id="suc" style="color: red;">&nbsp;未上传</span></td>
     </html:form>
    </tr>
    <tr>
     <td>
     上传备注: </td>
     <td colspan="4">
     <textarea name="faxRemark" id="faxRemark" rows="8" style="width: 100%;"></textarea>
     </td>
    </tr>
    </tbody>
   </table>
 
   <input type="hidden" id="faxpath" value="" />
   <div style="text-align: right;">
   <img src="../Image/zs.gif" style="margin-bottom: -3px;"/>&nbsp;&nbsp;<font color="#426EB4">提示:请上传doc、tiff文件</font>
   <br><br>
   <input type="button" value="发送传真" id="button" class="but" onclick="sendFax();" style="margin-right: 200px; cursor: hand;"/><input type="button" value="查看记录" id="button" class="but" onclick="location.href='../getSendFaxRecord.do';" style="margin-right: 300px;cursor: hand;"/>
   </div>
   <div id="hiddenDiv">
    <iframe id='upload_frame' name='upload_frame' src='' style="display: none;"></iframe>
   </div>
  <div id="massage_box">
   <div class="massage">
    <div class="header" onmousedown=MDown(massage_box)>
     <div style="display: inline; width: 150px; position: absolute">
      传真发送中请稍候
     </div>
     <span
      onClick="massage_box.style.visibility='hidden'; mask.style.visibility='hidden'"
      style="float: right; display: inline; cursor: hand">×</span>
    </div><br><br>
    <span id="fax_send_state" style="margin-left: 80px;color: green;">传真发送当中...</span>
   </div>
  </div>
  <div id="mask"></div>
  </div>
 </body>
 <script type="text/javascript">
    var workName='<bean:write scope="session" name="workerInfo" property="workername"/>';
function putFaxNo(){
  var faxNo='<%=String.valueOf(request.getParameter("faxNo"))%>';
  <%
   String fullname=String .valueOf(request.getParameter("fullName"));
       fullname= new String(fullname.getBytes("ISO8859-1"),"gb2312");
  %>
  var fullName='<%=fullname%>';
   if('null'==faxNo &&'null'==fullName){
    faxNo='';fullName=''; 
   }
   document.getElementById("phoneNo").value=faxNo;
   document.getElementById("fullName").value=fullName;
   document.getElementById("workName").value=workName;
 }
 function callClient(){
 var phone=document.getElementById("phoneNo").value;
   if(''!=phone&&null!=phone)
   parent.tops.OutCall2(phone);
 }
  function sendFax(){
 
     var path=document.getElementById("faxpath").value;
  
      if(path!=''&&path!=null){
        parent.tops.sendFax(path,1);
        document.getElementById("massage_box").style.visibility='visible';
       document.getElementById("mask").style.visibility='visible';
        window.setTimeout(send_state,3000);
        var d=new Date();
        document.getElementById("sendtime").value=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds();
        document.getElementById("sendstate").value="传真已发送";
      }
  }   
 function uploadSuc(uploadTime,uploadName,faxName,faxpath,faxsize){
 
   document.getElementById("uploadtime").value=uploadTime;
   document.getElementById("uploadname").value=uploadName;
   document.getElementById("faxname").value=faxName;
   document.getElementById("faxpath").value=faxpath;
   document.getElementById("faxsize").value=faxsize+"KB";
   document.getElementById("suc").innerHTML="<img src='../Image/suc.gif' style='margin-bottom: -4px;'/>";
 }     
 
 function uploadprintfile(){
 
    var regstr=/\\/;
    var reg=new  RegExp(regstr);
    var fval=document.getElementById("fax1").value;
    var full=document.getElementById("fullNmae").value;
   if(""==fval||""==full){
    if(full=="")alert("请填写接收传真公司名称!");else{ 
       alert("提示:未选择上传路径!"); 
    }
   }else{ 
     var s1=fval.split(reg,'100');  
            fval=s1[s1.length-1]; 
            fval=fval.substring(fval.length-3);   
     if("doc"==fval||"iff"==fval||"IFF"==fval){
      document.getElementById("suc").innerHTML="<img src='../Image/loading.gif' style='margin-bottom: -4px;'/>文件上传中请稍等...";
      document.uploadForm.submit();
     }else{
      alert("上传文件类型不匹配!");
     }
   }    
 }
 
  function openuploadfile(){
    var path=document.getElementById("faxpath").value;
        if(''!=path&&null!=path)
     document.location.href="../downloadSendFax.do?path="+path;
 }
 function send_state(){
  document.getElementById("massage_box").style.visibility='hidden';
  document.getElementById("mask").style.visibility='hidden';

 </script>
</html>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics