Since Microsoft limits the size of data submitted by POST, when the amount of data sent by the form is large, an error will be reported (error ASP 0107: 80004005). The reason is that Microsoft limits the maximum data that can be received using Request.Form() to 100K bytes. The solution to the problem is that for a domain that needs to send big data, split the data into several parts smaller than the limit before submitting the form, place them in several hidden fields, clear the original fields at the same time, and then formally submit the form. . The server still uses Request.Form() to read the data in each hidden field, and then splice them together in order. The main code is as follows:
Note: You need to specify a DIV within the HTML code in the Form to dynamically insert the hidden field into it.
====Client sample code====
Add: <div id=divHidden></div> to the HTML code in the Form. Add: onSubmit=return fnPreHandle(this) to the Form tag. Replace the BigField in the code below with the field in your form that submits the large database. name.
JavaScript code
Copy the code code as follows:
<script language=javascript>
//The data is split and placed in the corresponding hidden domain, which is triggered in the onSubmit event of the Form
function fnPreHandle(MyForm)
{
var iCount; //How many domains to split into
var strData; //original data
var iMaxChars = 50000;//Considering that Chinese characters are double bytes, the maximum number of characters in the domain is limited to 50K
var iBottleNeck = 2000000; //If the article exceeds 2M words, the user needs to be prompted
var strHTML;
//original data
strData = MyForm.BigField.value;
//If the article is too long, the user needs to be reminded
if (strData.length > iBottleNeck)
{
if (confirm(The article you want to publish is too long, it is recommended that you split it into several parts and publish them separately./nIf you insist on submitting, please note that it will take a long time to submit successfully./n/nDo you insist on submitting?) == false )
return false;
}
iCount = parseInt(strData.length / iMaxChars) + 1;
//hdnCount records how many sub-domains the original data domain is split into
strHTML = <input type=hidden name=hdnCount value= + iCount + >;
//Generate HTML code for each subdomain
for (var i = 1; i <= iCount; i++)
{
strHTML = strHTML + /n + <input type=hidden name=hdnBigField + i + >;
}
//Dynamicly insert the HTML code of each hidden field into the DIV (divHidden) in the Form
document.all.divHidden.innerHTML = strHTML;
//Assign values to each subfield
for (var i = 1; i <= iCount; i++)
{
MyForm.elements[hdnBigField + i].value = strData.substring((i - 1) * iMaxChars, i * iMaxChars);
}
//Clear the original data field
MyForm.BigField.value = ;
}
</script>
Server-side sample code ASP/Visual Basic code
Copy the code code as follows:
<%
Dim strData
Dim intFieldCount
Dim i
intFieldCount = Request.Form(hdnCount)
For i=1 To intFieldCount
strData = strData & Request.Form(hdnBigfield & i)
Next
Response.Write strData
%>