`
happmaoo
  • 浏览: 4347563 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

在Form域中Post大于100K的数据

阅读更多

当表单发送的数据量很大时,就会报错。查阅MSDN了解到,原因是微软对用Request.Form()可接收的最大数据有限制,IIS4中为80K字节,IIS5中为100K字节。

  下面是微软提供的几个解决方法:

1、用Request.BinaryRead代替Request.Form方法来解析表单数据;

2、使用文件上传方案,比如:MicrosoftPostingAcceptor;

3、由于102399字节的限制是对每个表单元素的,所以在提交时,把表单元素内容大于102399的分隔成多个表单元素来提交。

下面为示例代码:(微软提醒:下面代码不一定完全适用特定的需要,不对使用这些代码产生的后果负责!)

<FORMmethod=postaction=LargePost.aspname=theFormonsubmit="BreakItUp()">
<Textarearows=3cols=100name=BigTextArea>Abunchoftext...</Textarea>
<inputtype=submitvalue=go>
</form>
<SCRIPTLanguage=JavaScript>
functionBreakItUp()
{
//Setthelimitforfieldsize.
//如果内容有中文的字符的话,可以设置为:51100
varFormLimit=102399
//Getthevalueofthelargeinputobject.
varTempVar=newString
TempVar=document.theForm.BigTextArea.value
//Ifthelengthoftheobjectisgreaterthanthelimit,breakit
//intomultipleobjects.
if(TempVar.length>FormLimit)
{
document.theForm.BigTextArea.value=TempVar.substr(0,FormLimit)
TempVar=TempVar.substr(FormLimit)
while(TempVar.length>0)
{
varobjTEXTAREA=document.createElement("TEXTAREA")
objTEXTAREA.name="BigTextArea"
objTEXTAREA.value=TempVar.substr(0,FormLimit)
document.theForm.appendChild(objTEXTAREA)

TempVar=TempVar.substr(FormLimit)
}
}
}
</SCRIPT>



接受数据页主要代码:

<%
DimBigTextArea
ForI=1ToRequest.Form("BigTextArea").Count
BigTextArea=BigTextArea&Request.Form("BigTextArea")(I)
Next
%>

来源:www.skyec.com添加时间:2004-6-3 16:19:03
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics