晒晒效果
源码
- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
- <%
- Option Explicit
- With Response
- .Expires=-1
- .ExpiresAbsolute=NOW-1
- .CacheControl="no-cache"
- .AddHeader "Pragme","no-cache"
- .Buffer=true
- End With
- Dim action,formvalue,formvalueLen,fso,ts
- formvalue=Trim(Request.Form("txtarea"))
- formvalueLen=Len(formvalue)
- If formvalue<>"" or formvalue<>null Then
- Set fso=Server.CreateObject("Scripting.FileSystemObject")
- Set ts=fso.CreateTextFile(Server.MapPath(formvalueLen&".txt"),True,True)
- ts.Write(formvalue)
- ts.Close
- Set ts=Nothing
- Set fso=Nothing
- End If
- %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
- <title>我要看看TextStream的Write方法能写入多少字符</title>
- <script language="javascript" type="text/javascript">
- function ShowTextCount(val){
- valval=val.replace(/(^/s*)|(/s*$)/g,""); //替换前后空格相当于vbscript Trim()函数
- document.getElementById("showtextresult").innerText="您输入的字符数:"+val.length;
- }
- </script>
- <style type="text/css">
- #txtarea{width:600px;height:300px;display:block;}
- span{color:red;}
- </style>
- </head>
- <body>
- <form method="post" action="TextStreamWriteDemo.asp">
- <textarea name="txtarea" id="txtarea" onkeyup="ShowTextCount(this.value);"></textarea>
- <input type="submit" value="提交"/>
- <input type="reset"/>
- <span id="showtextresult">写入了<%=formvalueLen%>个字符</span>
- </form>
- </body>
- </html>
生成结果
![](https://p-blog.csdn.net/images/p_blog_csdn_net/veiny/EntryImages/20081121/dic.gif)
TextStream的Write方法能写入文件,据说能写入20亿个字符。仅仅测试到40w个字符,文件就将近800k了。实际中够用了。不过往浏览器textarea拷贝40w字符就快把浏览器搞崩溃了~!