使用是swfupload做了一个多文件上传。但是在上传的时候,文件名是乱码,该怎么解决呢?还有,我获取页面上的编号传到后台,采用post_params: {"org_id" :document.getElementById("org_id").value},获取参数值,为什么值总是空的呢。下面是上传页面。
<%@ page language="java" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort() + path + "/"; 
StringBuffer uploadUrl = new StringBuffer("http://");
uploadUrl.append(request.getHeader("Host"));
uploadUrl.append(new String(request.getContextPath().getBytes("UTF-8"),"GBK"));
uploadUrl.append("/page/termSoftware/upload.jsp");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>:: 诺威自助服务管理系统 - 后台管理 ::</title>
<base href="<%=basePath%>"/>
<link href="../../css/sec.css" rel="stylesheet" type="text/css" />
<base target="mainFrame" />
      
<script type="text/javascript" src="/page/termSoftware/js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="/page/termSoftware/js/swfupload/handlers.js"></script>
<script type="text/javascript">
var swfu;
window.onload = function () {
swfu = new SWFUpload({
   flash_url : "/page/termSoftware/js/swfupload/swfupload.swf",
upload_url: "<%=uploadUrl.toString()%>",
post_params: {"org_id" :document.getElementById("org_id").value},

// File Upload Settings
file_size_limit : "10 MB", // 1000MB
file_types : "*.*",
file_types_description : "所有文件",
file_upload_limit : "0",

file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete,//选择好文件后提交
file_queued_handler : fileQueued,
upload_progress_handler : uploadProgress,
upload_error_handler : uploadError,
upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete,

// Button Settings
button_image_url : "/page/termSoftware/images/SmallSpyGlassWithTransperancy_17x18.png",
button_placeholder_id : "spanButtonPlaceholder",
button_width: 180,
button_height: 18,
button_text : '<span class="button">选择文件 <span class="buttonSmall">(10 MB Max)</span></span>',
button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
button_text_top_padding: 0,
button_text_left_padding: 18,
button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
button_cursor: SWFUpload.CURSOR.HAND,

// Flash Settings


custom_settings : {
upload_target : "divFileProgressContainer"
},
// Debug Settings
debug: false  //是否显示调试窗口
});
};
function startUploadFile(){
swfu.startUpload();
}


var win = new Ext.Window({
title : 'SwfUpload',
closeAction : 'hide',
width : 750,
height : 360,
resizable : false,
modal : true,

html : '<iframe src="/page/termSoftware/index.jsp?org_id="document.getElementById("org_id").value"" width="100%" height="100%"></iframe>'
});
function showExtShow(){
win.show();
}
</script>
</head>
<body style="background-color: #FFFFFF; padding: 4px;">
<form name="termsoftForm" id="termsoftForm" method="post" action="/termsoft.do" enctype="multipart/form-data"><input type="hidden" name="command" value="uploadTermSoft" /><table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="26" bgcolor="#E1F0FB">
<div class="help_left">   
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>  
          <td width="11">&nbsp;</td>
          <td width="17"><img src="../../images/now_icon.jpg" width="10" height="10" /></td>
          <td>当前位置:终端软件下发</td>
          <td>&nbsp;</td>
        </tr>
      </table>
</div>
<div class="help">
<a href="#"><img src="../../images/sec_help.jpg" border="0"/></a>
</div>
</td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="56" rowspan="2"><img src="../../images/sec_nav_left.jpg" width="56" height="29" /></td>
        <td height="24" style="background:#79AAD3 url(../../images/sec_nav_up_bg.jpg) no-repeat;">
<div style="margin-top:4px;">
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="right_nav">
          <tr>
            <td>二级导航:&nbsp;&nbsp;&nbsp;<strong>
          <a href="/page/termSoftware/uploadTermSofst.jsp">AA</a>
            </strong></td>
          </tr>
        </table>
</div>
</td>
      </tr>
      <tr>
        <td height="5" style="background:#234158 url(../../images/sec_nav_up_down.jpg) no-repeat;"></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td background="../../images/sec_right_title.jpg"><table width="100%" height="44" border="0" cellpadding="0" cellspacing="0" style="background:url(../../images/sec_right_word_bg.jpg) no-repeat 505px;">
      <tr>
        <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="18">&nbsp;</td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="25">&nbsp;</td>
                <td width="24"><img src="../../images/right_title_icon.jpg" width="14" height="16" /></td>
                <td class="right_top_title">终端软件下发</td>
              </tr>
            </table></td>
          </tr>
        </table></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td>
<div class="add_right">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="116">&nbsp;</td>
<td><table width="150%" border="0" cellspacing="6" cellpadding="0">
       <tr>
        <td width="83"></td>
        <td colspan="10"></td>
      </tr>
      <tr>
        <td width="100" align="center" valign="middle">选择机构:</td>
        <td colspan="10">
  <input type="text" name="org_id"></input>
        </td>        
      </tr>         
      <tr>
      
        <td width="100" align="center" valign="middle">软件上传:</td>        <td colspan="10">
        
<div
style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;">
<span id="spanButtonPlaceholder"></span>
<input id="btnUpload" type="button" value="上  传"
onclick="startUploadFile();" class="btn3_mouseout" onmouseup="this.className='btn3_mouseup'"
onmousedown="this.className='btn3_mousedown'"
onmouseover="this.className='btn3_mouseover'"
onmouseout="this.className='btn3_mouseout'"/>
<input id="btnCancel" type="button" value="取消所有上传"
onclick="cancelUpload();" disabled="disabled" class="btn3_mouseout" onmouseup="this.className='btn3_mouseup'"
onmousedown="this.className='btn3_mousedown'"
onmouseover="this.className='btn3_mouseover'"
onmouseout="this.className='btn3_mouseout'"/>
</div>
<div id="divFileProgressContainer"></div>
<div id="thumbnails">
<table id="infoTable" border="0" width="470" style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;margin-top:8px;">
</table>
</div>

</td>
      </tr>         
    </table></td>
</tr>
</table>
</div>
</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>
  </tr>
</form>
</body>
</html>

解决方案 »

  1.   

    使用是swfupload做了一个多文件上传。但是在上传的时候,文件名是乱码,该怎么解决呢?还有,我获取页面上的编号传到后台,采用post_params: {"org_id" :document.getElementById("org_id").value},获取参数值,为什么值总是空的呢。下面是上传页面。
    <%@ page language="java" pageEncoding="UTF-8"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
    + request.getServerName() + ":" + request.getServerPort() + path + "/"; 
    StringBuffer uploadUrl = new StringBuffer("http://");
    uploadUrl.append(request.getHeader("Host"));
    uploadUrl.append(new String(request.getContextPath().getBytes("UTF-8"),"GBK"));
    uploadUrl.append("/page/termSoftware/upload.jsp");
    %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@ page contentType="text/html;charset=UTF-8" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>:: 诺威自助服务管理系统 - 后台管理 ::</title>
    <base href="<%=basePath%>"/>
    <link href="../../css/sec.css" rel="stylesheet" type="text/css" />
    <base target="mainFrame" />
          
    <script type="text/javascript" src="/page/termSoftware/js/swfupload/swfupload.js"></script>
    <script type="text/javascript" src="/page/termSoftware/js/swfupload/handlers.js"></script>
    <script type="text/javascript">
    var swfu;
    window.onload = function () {
    swfu = new SWFUpload({
       flash_url : "/page/termSoftware/js/swfupload/swfupload.swf",
    upload_url: "<%=uploadUrl.toString()%>",
    post_params: {"org_id" :document.getElementById("org_id").value},

    // File Upload Settings
    file_size_limit : "10 MB", // 1000MB
    file_types : "*.*",
    file_types_description : "所有文件",
    file_upload_limit : "0",

    file_queue_error_handler : fileQueueError,
    file_dialog_complete_handler : fileDialogComplete,//选择好文件后提交
    file_queued_handler : fileQueued,
    upload_progress_handler : uploadProgress,
    upload_error_handler : uploadError,
    upload_success_handler : uploadSuccess,
    upload_complete_handler : uploadComplete,

    // Button Settings
    button_image_url : "/page/termSoftware/images/SmallSpyGlassWithTransperancy_17x18.png",
    button_placeholder_id : "spanButtonPlaceholder",
    button_width: 180,
    button_height: 18,
    button_text : '<span class="button">选择文件 <span class="buttonSmall">(10 MB Max)</span></span>',
    button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
    button_text_top_padding: 0,
    button_text_left_padding: 18,
    button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
    button_cursor: SWFUpload.CURSOR.HAND,

    // Flash Settings


    custom_settings : {
    upload_target : "divFileProgressContainer"
    },
    // Debug Settings
    debug: false  //是否显示调试窗口
    });
    };
    function startUploadFile(){
    swfu.startUpload();
    }


    var win = new Ext.Window({
    title : 'SwfUpload',
    closeAction : 'hide',
    width : 750,
    height : 360,
    resizable : false,
    modal : true,

    html : '<iframe src="/page/termSoftware/index.jsp?org_id="document.getElementById("org_id").value"" width="100%" height="100%"></iframe>'
    });
    function showExtShow(){
    win.show();
    }
    </script>
    </head>
    <body style="background-color: #FFFFFF; padding: 4px;">
    <form name="termsoftForm" id="termsoftForm" method="post" action="/termsoft.do" enctype="multipart/form-data"><input type="hidden" name="command" value="uploadTermSoft" /><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="26" bgcolor="#E1F0FB">
    <div class="help_left">   
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>  
              <td width="11">&nbsp;</td>
              <td width="17"><img src="../../images/now_icon.jpg" width="10" height="10" /></td>
              <td>当前位置:终端软件下发</td>
              <td>&nbsp;</td>
            </tr>
          </table>
    </div>
    <div class="help">
    <a href="#"><img src="../../images/sec_help.jpg" border="0"/></a>
    </div>
    </td>
      </tr>
      <tr>
        <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="56" rowspan="2"><img src="../../images/sec_nav_left.jpg" width="56" height="29" /></td>
            <td height="24" style="background:#79AAD3 url(../../images/sec_nav_up_bg.jpg) no-repeat;">
    <div style="margin-top:4px;">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="right_nav">
              <tr>
                <td>二级导航:&nbsp;&nbsp;&nbsp;<strong>
              <a href="/page/termSoftware/uploadTermSofst.jsp">AA</a>
                </strong></td>
              </tr>
            </table>
    </div>
    </td>
          </tr>
          <tr>
            <td height="5" style="background:#234158 url(../../images/sec_nav_up_down.jpg) no-repeat;"></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td background="../../images/sec_right_title.jpg"><table width="100%" height="44" border="0" cellpadding="0" cellspacing="0" style="background:url(../../images/sec_right_word_bg.jpg) no-repeat 505px;">
          <tr>
            <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="18">&nbsp;</td>
              </tr>
              <tr>
                <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="25">&nbsp;</td>
                    <td width="24"><img src="../../images/right_title_icon.jpg" width="14" height="16" /></td>
                    <td class="right_top_title">终端软件下发</td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td>
    <div class="add_right">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
    <td width="116">&nbsp;</td>
    <td><table width="150%" border="0" cellspacing="6" cellpadding="0">
           <tr>
            <td width="83"></td>
            <td colspan="10"></td>
          </tr>
          <tr>
            <td width="100" align="center" valign="middle">选择机构:</td>
            <td colspan="10">
      <input type="text" name="org_id"></input>
            </td>        
          </tr>         
          <tr>
          
            <td width="100" align="center" valign="middle">软件上传:</td>        <td colspan="10">
            
    <div
    style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;">
    <span id="spanButtonPlaceholder"></span>
    <input id="btnUpload" type="button" value="上  传"
    onclick="startUploadFile();" class="btn3_mouseout" onmouseup="this.className='btn3_mouseup'"
    onmousedown="this.className='btn3_mousedown'"
    onmouseover="this.className='btn3_mouseover'"
    onmouseout="this.className='btn3_mouseout'"/>
    <input id="btnCancel" type="button" value="取消所有上传"
    onclick="cancelUpload();" disabled="disabled" class="btn3_mouseout" onmouseup="this.className='btn3_mouseup'"
    onmousedown="this.className='btn3_mousedown'"
    onmouseover="this.className='btn3_mouseover'"
    onmouseout="this.className='btn3_mouseout'"/>
    </div>
    <div id="divFileProgressContainer"></div>
    <div id="thumbnails">
    <table id="infoTable" border="0" width="470" style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 2px;margin-top:8px;">
    </table>
    </div>

    </td>
          </tr>         
        </table></td>
    </tr>
    </table>
    </div>
    </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>
      </tr>
    </form>
    </body>
    </html>