格式错误的多部分POST:数据被截断

时间:2016-02-16 06:42:02

标签: html cgi

每当我尝试上传文件时,网络服务器都会返回"格式错误的多部分POST:数据被截断"错误。

出现此错误的原因是代码错误还是服务器问题

这是用于文件验证和提交的JavaScript代码:

    function loadFile() 
{
    var input, file, fr;

    if (typeof window.FileReader !== 'function') {
        bodyAppend("p", "The file API isn't supported on this browser yet.");
        return;
    }

    input = document.getElementById('fileinput');
    if (!input) {
        bodyAppend("p", "Um, couldn't find the fileinput element.");
    }
    else if (!input.files) {
        bodyAppend("p", "This browser doesn't seem to support the `files` property of file inputs.");
    }
    else if (!input.files[0]) {
        bodyAppend("p", "Please select a file before clicking 'Load'");
    }
    else {
        file = input.files[0];
        fr = new FileReader();
        fr.onload = receivedText;
        fr.readAsText(file);
      }

    function receivedText() {
        showResult(fr, "Text");

        //fr = new FileReader();
        //fr.onload = receivedBinary;
        //fr.readAsBinaryString(file);
    }

    function receivedBinary() {
        showResult(fr, "Binary");
    }
}

function showResult(fr, label) {
    var markup, result, n, aByte, byteStr,byteStr1='';

    markup = [];
    result = fr.result;
    for (n = 24; n < 63; ++n) {
        aByte = result.charCodeAt(n);
        byteStr = aByte.toString(16);
        if (byteStr.length < 2) {
            byteStr = byteStr;
        }
        byteStr1 +=byteStr;
    }
 var hex = byteStr1;//force conversion
 var str = '';
 for (var i = 0; i < hex.length; i += 2)
    str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));

  input = document.getElementById('fileinput');
  if(str === input.value)
  {

  document.getElementById('fspdump').submit();

  }
  else{
   alert("Try again with original FSPDUMP file");

   }
   }

function bodyAppend(tagName, innerHTML) {
    var elm;

    elm = document.createElement(tagName);
    elm.innerHTML = innerHTML;
    document.body.appendChild(elm);
}

HTML代码

    <form name="fspdump" id='fspdump'  action="cgi-bin/original.cgi enctype="multipart/form-data" method="post"  />

Select a file to Upload
<input type='file' id='fileinput'>
<input type='button' id='btnLoad' value='Validate' onclick='loadFile();'>

<input type="reset" name="reset" value="Reset" />

0 个答案:

没有答案