当前位置: 首页 > 图文教程 > 网络编程 > ASP > 在Form域中Post大于100K的数据

ASP
ASP编程中20个非常有用的例子
省名与城名下拉选择框联动
ASP有函数可以把某个网页通过STREAM下载吗?
用Regular Expression来改变HTML代码
控制输出字符串的长度,可以区别中英文
教你做小偷程序 容易学
小偷程序原理和简单示例
好漂亮的钟[代码]
实现WEB中的@虚拟域名系统 原理篇
ASP对excel的操作
将服务器端文件夹下的文件,按文件建立的时间先后排序
存储过程编写经验和优化措施
存储过程入门
在ASP中怎樣用Excel寫報表
在ASP中使用Oracle数据库技巧(1)
在ASP中使用Oracle数据库技巧(2)
在ASP中使用断开的记录集
披著羊皮的大野狼 Session
两级联动的select XML版
判断checkbox是否至少有选择一项

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 33 ::
收藏到网摘: n/a

       当表单发送的数据量很大时,就会报错。查阅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
  %>