當表單發送的數據量很大時,就會報錯。查閱MSDN了解到,原因是微軟對用Request.Form()可接收的最大數據有限制,IIS4中為80K字節,IIS5中為100K字節。 下面是微軟提供的幾個解決方法: 1、用Request.BinaryRead 代替 Request.Form方法 來解析表單數據; 2、使用文件上傳方案,比如:Microsoft Posting Acceptor; 3、由于102399字節的限制是對每個表單元素的,所以在提交時,把表單元素內容大于102399的分隔成多個表單元素來提交。 下面為示例代碼:(微軟提醒:下面代碼不一定完全適用特定的需要,不對使用這些代碼產生的后果負責!) <FORM method=post action=LargePost.asp name=theForm onsubmit="BreakItUp()"> <Textarea rows=3 cols=100 name=BigTextArea>A bunch of text...</Textarea> <input type=submit value=go> </form> <SCRIPT Language=JavaScript> function BreakItUp() { //Set the limit for field size. //如果內容有中文的字符的話,可以設置為:51100 var FormLimit = 102399 //Get the value of the large input object. var TempVar = new String TempVar = document.theForm.BigTextArea.value //If the length of the object is greater than the limit, break it //into multiple objects. if (TempVar.length > FormLimit) { document.theForm.BigTextArea.value = TempVar.substr(0, FormLimit) TempVar = TempVar.substr(FormLimit) while (TempVar.length > 0) { var objTEXTAREA = document.createElement("TEXTAREA") objTEXTAREA.name = "BigTextArea" objTEXTAREA.value = TempVar.substr(0, FormLimit) document.theForm.appendChild(objTEXTAREA) TempVar = TempVar.substr(FormLimit) } } } </SCRIPT> 接受數據頁主要代碼: <% Dim BigTextArea For I = 1 To Request.Form("BigTextArea").Count BigTextArea = BigTextArea & Request.Form("BigTextArea")(I) Next %>
|