FireFox下面文件上傳session丟失狀況

前段時間在作項目的時候用到了JQuery的一個上傳插件,可是呢,在火狐下面上傳的時候在後臺怎麼也獲取不到一些信息,後來才發現原來是session丟失了,個人解決方案很簡單,直接是把要獲取的信息加到上傳的url後面,而後再從後來截取出來,這樣就不會丟失了javascript

image這些信息是要傳遞到後臺處理的有用信息,可是session丟失了,用戶信息後臺獲取不到,image經過加載url後面,具體代碼以下:css

 

<%@page import="com.sun.corba.se.spi.servicecontext.UEInfoServiceContext,java.util.*"%>
<%@ page language="java"  contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%
    String videoinfo = request.getParameter("video_Info");
    List<String> list = (List<String>)request.getSession().getAttribute("videoName");
    String userAcc = request.getSession().getAttribute("userAccount").toString();
    String userName = request.getSession().getAttribute("userName").toString();
    String userOrg = request.getSession().getAttribute("userOrg").toString();
    String videoInfo = videoinfo + "~" + userName + "~" + userOrg;//要傳遞到後臺的信息
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>批量上傳界面</title>
</head>
      <!-- 驗證仍是jquery-validation好用,這裏省事沒用 -->
  <body>
           <script src="${ctx}/resources/js/jquery-1.8.3.js"></script>
         <link rel="stylesheet" type="text/aacss" href="${ctx}/resources/css/uploadify.css" />
        <script src="${ctx}/resources/js/jquery.uploadify.js"></script>
        <script src="${ctx}/resources/js/jquery.uploadify.min.js"></script>
        <style type="text/css"> 
        .loginButton
        {
          background:#E1E9DC;
            width:80px;
            height:30px;
            border:none;
            font-size:13px;
            font-family: 微軟雅黑;
            border-top:1px solid #1C7887;
            border-left:1px solid #1C7887;
            border-right:1px solid #1C7887;
            border-bottom:1px solid #1C7887;
            cursor:pointer;
        }html

        .uploadify-button {
            width:80px;
            height:30px;
            border:none;
        }   
    </style>
<script type="text/javascript"  >
    $(function(){
        //alert(window.parent.document.getElementById("add_info").value);
        //var uploadify_url = window.parent.document.getElementById("add_info").value;
        var uploadify_url = '${ctx}/video/createMoreVideo;jsessionid=<%=request.getSession().getId()%>?videoinfo='+encodeURIComponent('<%=videoInfo%>');//加載後面直接傳遞
        
        $("#uploadify").uploadify({
            "uploader":uploadify_url,
            "swf": '${ctx}/resources/js/uploadify.swf',
            'script': '',
            "buttonClass":"uploadify-button",
            "buttonText":"<div class='loginButton'>選擇文件</div>",
            'width': 79,//buttonImg的大小
            'height': 30,//
            "folder":"UploadFile", //文件上傳路徑
            "queueID":"fileQueue", //div層的id
            "auto":false, //是否當即上傳
            "progressData":"percentage",
            "multi":true , //是否支持多文件上傳
            "queueSizeLimit":10 ,//最多上傳文件個數
            "fileSizeLimit":'204800KB', //文件的最大值200M204800KB
            "removeTimeout":'2',
            "removeCompleted": false,
            "fileTypeExts":"*.avi" ,//文件的格式
            "fileTypeDesc": "請選擇avi格式的文件", //設置文件上傳格式顯示文字
            'onQueueComplete' : function(queueData) {
                alert('全部文件上傳完成');
                window.close();
                //$('#myPop2Window').window('close');
            },
            'onSelect' : function(file) {
                //alert('The file ' + file.name + ' was added to the queue.');
                if(file.name.split("_").length!=5) {
                    alert("'"+file.name+"'視頻名稱格式不正確,如:中國銀行_廣告_198_1609_中行家庭財產保險遊.avi");
                    $('#uploadify').uploadify('cancel', file.id);
                }
                if(file.name.split(".").length!=2) {
                    alert("'"+file.name+"'視頻名稱格式不正確,如:中國銀行_廣告_198_1609_中行家庭財產保險遊.avi");
                    $('#uploadify').uploadify('cancel', file.id);
                }
                <%
                for(int i = 0; i < list.size();i++){
                        String name = list.get(i);
                    %>
                    if(file.name=='<%=name%>'){
                        alert(file.name+"視頻已上傳過,請從新選擇!!");
                        $('#uploadify').uploadify('cancel', file.id);
                    }
                    <%
                }
                %>
            },
            "onUploadSuccess": function(file, data, response){
                //在每個文件上傳成功或失敗以後觸發,返回上傳的文件對象或返回一個錯誤,若是你想知道上傳是否成功,最後使用onUploadSuccess或onUploadError事件
                //alert(data);
            },
            'onClearQueue' : function(queueItemCount){
                alert(queueItemCount + ' file(s) were removed from the queue');
            },
            "onUploadProgress": function(file,bytesUploaded,bytesTotal,totalBytesUploaded,totalBytesTotal){
                $('#pregress').html('總共須要上傳'+bytesTotal+'字節,'+'已上傳'+totalBytesTotal+'字節')
            },
            "onCancel" : function(file) {
                        //alert('The file ' + file.name + ' was cancelled.');
                                         },
           'onFallback' : function() {
                alert('Flash was not detected.');
            }
        });
   
     });java

    
 
     
    </script>
    <form  id="videoAddForm" method="post" style="text-align: center;background-color: #D7D7D9;width: 100%" enctype ="multipart/form-data">
       
        <table width="100%" border="0px">
            <tr>
            <td><input  type="file" name="uploadify" id="uploadify" /></td>
            <td><input class="loginButton" value="提交" type="button" onclick="javascript:$('#uploadify').uploadify('upload','*')" ></td>
            <td><input class="loginButton" value="所有清除" type="button" onclick="javascript:$('#uploadify').uploadify('cancel', '*')" ></td>
            </tr>
            <tr>
                <td colspan="4" width="100%" height="100%">
                    <div id="fileQueue" style="width: 400;height: 350;"></div>       
                </td>
            </tr>
        </table>
    </form>
    </body>
</html>jquery

相關文章
相關標籤/搜索