2017-02-17 1 views
1

Мне нужно отправить файл с компьютера на встроенный сервер, и для целей тестирования выведите его в Hyperterminal, чтобы узнать, что было получено. Если мы посмотрим на компьютер в Инструментах разработчика F12 «Сеть», Тело обычно правильно, но иногда строки 3 являются дубликатом строки 2. На стороне сервера полученная строка повторяется для всей передачи. Для целей тестирования это файл:Полученные строки передачи файлов Internet Explorer повторяются при использовании сообщений или iframes

$A80000032W18%L6C3100D8 
$A8000009EW18%LC31600D8 
$A8000010AW18%LC31600D8 
$A80000176W18%L532F00D8 
$A800001E2W18%L22A200D8 
$A800002BAW18%L393700D8 
$A80000326W18%LE77600D8 
$A80000392W18%L5E1900D8 
$A800003FEW18%L488600D8 
$A8000046AW18%LC77300D8 
$A800004D6W18%L904500D8 
$A80000542W18%L9F1800D8 
$A800005AEW18%L76D400D8 
$AEND 

Любые предложения? Эта передача работает нормально с Chrome и Firefox, но не с IE и Edge.

+0

Вы должны вставить свой тестовый код – cuixiping

ответ

0
 <!DOCTYPE html> 
     <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> 
     <title>MS-Sedco Intersector Server</title> 
     <link href="toplevel.css" rel="stylesheet" type="text/css" /> 

     </head> 
     <body> 


     <form name=connect > 
     <pre> 




       <input id="ConnType" type="submit" name=misce onclick="connecting()" value="Connect to Radar" size="2"> 
      <input id="ConnStatus" type="hidden" name=Conn value="*DA;" size="2"> 
     </pre> 
     </form> 
     <pre> 
      <input type="file" onchange='readText(this)' size="2"> 
     </pre> 

     <pre> 

      <input type="button" onclick="program_boot()" value="Program" size="2"> 
     </pre> 

     <pre> 

      <div id=BootStatus> </div> <div id=BootAddress> </div> <div id=b_test> </div> 
     </pre> 


     <form name=RTimeout> 
     <input type="hidden" name=misce value="RTimeout" size="2"> 
     </form> 

     <form id="ie-fix" name="ie-fix" action="RadarBootLoader.htm" method="POST" target="booter-loader"> 
      <input type="hidden" id="dataIE" name="" /> 
     </form> 
     <iframe src="" id="boot-loader" name="boot-loader" style="display:none" width="100%" height="600"></iframe> 

     </body> 

     <script language="JavaScript"> 
     ////////////////////////////////////////////////////////////////////////////////////// 
     // Variables global to script 
     ////////////////////////////////////////////////////////////////////////////////////// 
     var Temp_id; 
     var txt; 
     var etime; 
     var index; 
     var bootindex; 
     var output; 
     var address; 
     var done = 0; 
     var lastlineindex; 
     var prog_state = 0; 
     var sendout; 
     var reader = new FileReader(); 
     var interval; 

     if (document.getElementById("ConnStatus").value == 1) 
     { 
      document.getElementById('BootStatus').innerHTML= " Radar Boot Connected"; 
     } 


     function readText(that){ 

        if(that.files && that.files[0]){ 
         reader.onload = function (e) { 
          output=e.target.result; 

          //process text to show only lines with "@":    
          //output=output.split("\n").filter(/./.test, /\@/).join("\n"); 
          output=output.split("\n") 
          document.getElementById('BootStatus').innerHTML= output; 
          sendout = output[0]; 
         };//end onload() 
         reader.readAsText(that.files[0]); 
        }//end if html5 filelist support 
     } 

     function alertContents(httpRequest){ 
      if (httpRequest.readyState == 4){ 
       // everything is good, the response is received 
       if ((httpRequest.status == 200) || (httpRequest.status == 0)){ 
       txt = httpRequest.responseText; 
       document.getElementById('BootStatus').innerHTML = httpRequest.responseText; 
       if ((httpRequest.responseText).indexOf("Load Complete") > -1) 
       { 
        prog_state = 0; 
        if (done) 
        { 
         //done = 0; 
        //bootindex = 0; 
        clearInterval(etime); 
         document.getElementById('BootStatus').innerHTML = " Program Finished !!!"; 
        } 
        else 
        { 
        //clearInterval(etime); 
         //etime = setTimeout("timeout()", 1); 
         //document.getElementById('BootStatus').innerHTML = " Program Radar Flash Memory"; 
         bootindex++; 
        sendout = output[bootindex]; 
          if ((output[bootindex]).indexOf("END") > -1) 
        { 
        done = 1; 
        } 
          else if ((output[bootindex]).indexOf("$A") > -1) 
        { 
        address = "0x" + (output[bootindex]).substr(2, 8); 
         document.getElementById('BootAddress').innerHTML= " " + address;   
        } 
        //console.log(sendout); 

        if (window.XMLHttpRequest) { 
        send_with_ajax('RadarBootLoader.htm'); 
        } else { 
        // Here is the IE fix test code 
        var iframe = document.getElementById("boot-loader"); 
        var iframeDoc = iframe.contentDocument || iframe.contentWindow.document; 

        document.getElementById("dataIE").value = sendout; 
        document.getElementById("ie-fix").submit(); 
        interval = setInterval(iframe_loaded, 2000); 
        } 
        } 
       } 
       //alert(bootindex); 
        //alert("The response was: " + httpRequest.status + httpRequest.responseText); 
       //alert((httpRequest.responseText).indexOf("bindex")); 
       //alert(document.getElementById("BootInd").value); 
       }else{ 
        alert('There was a problem with the request. ' + httpRequest.status + httpRequest.responseText); 
       } 
      } 
     } 

     function iframe_loaded() { 
      var iframe = document.getElementById("boot-loader"); 
      var iframeDoc = iframe.contentDocument || iframe.contentWindow.document; 
      var httpRequest = { 
      readyState: 4, 
      status: 200, 
      responseText: "Load Complete" 
      }; 

      console.log(iframeDoc.readyState); 
      if (iframeDoc.readyState == "complete") { 
      clearInterval(interval); 
      alertContents(httpRequest); 
      } 
     } 

     function send_with_ajax(url) 
     { 
      var http_request = false; 

       if (window.XMLHttpRequest) 
      { // Mozilla, Safari,... 
        http_request = new XMLHttpRequest(); 
         if (http_request.overrideMimeType) 
       { 
          //http_request.overrideMimeType('text/xml'); 
         } 
       } 
      else if (window.ActiveXObject) 
      { // IE 
       try { 
          http_request = new ActiveXObject("text/xml"); 
        } 
        catch(e){ 
        try 
        { 
          http_request = new ActiveXObject("text/xml"); 
          } 
        catch (e) 
        { 
          try 
        { 
            http_request = new ActiveXObject("Microsoft.XMLHTTP"); 
          } 
        catch (e) {} 
          } 
        } 
       } 

       if (!http_request) 
      { 
        alert('Giving up :(Cannot create an XMLHTTP instance'); 
         return false; 
       } 

       document.getElementById('b_test').innerHTML = bootindex; 

      if (window.XMLHttpRequest) { 
       http_request.onreadystatechange = function() { alertContents(http_request); }; 
        http_request.open('POST', url, true); 
       http_request.setRequestHeader('Content-type', 'multipart/form-data'); 
       http_request.setRequestHeader('Content-Encoding', "gzip"); 
        http_request.send(sendout); 
      } else { 
       iframe_loaded(); 
      } 
     } 


     function connecting() 
     { 
      document.getElementById('BootStatus').innerHTML= " Connecting Radar Boot Loader"; 
     } 

     function program_boot() 
     { 
      document.getElementById('BootStatus').innerHTML= " Waiting Radar Echo"; 
      etime = setTimeout("timeout()", 10000); 
      prog_state = 1; 
      send_with_ajax('RadarBootLoader.htm'); 
     } 

     function timeout() 
     { 
      if (prog_state == 1) 
      { 
       done = 0; 
       bootindex = 0; 
       alert("Can not Program Flash Memory !!"); 
       document.getElementById('BootStatus').innerHTML= " "; 
       clearInterval(etime); 
       document.RTimeout.submit(); 
      } 
      /*else 
      { 
       clearInterval(etime); 
       send_with_ajax('RadarBootLoader.htm'); 
       document.getElementById('b_test').innerHTML = bootindex; 
       //etime = setTimeout("timeout()", 10); 
      }*/ 
     } 

     ////////////////////////////////////////////////////////////////////////////////////// 
     // Infinite loop with delay 
     ////////////////////////////////////////////////////////////////////////////////////// 
     function loop() 
     { 
      bootindex = 0; 
     } 


     ////////////////////////////////////////////////////////////////////////////////////// 
     // Run 
     ////////////////////////////////////////////////////////////////////////////////////// 
     window.onload=loop; 


     </script> 
     </html> 
Смежные вопросы