日期:2014-05-17  浏览次数:21162 次

表单提交中文乱码问题
<%@   CODEPAGE=65001   %>
<%   Response.Charset= "UTF-8 "   %>  
<HTML>
<HEAD>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=utf-8 "   />
</head>
<body>
<form   action= "upload.asp "   method= "post "   enctype= "multipart/form-data ">
<input   type= "text "   name= "uname ">
<input   type= "submit "   name= "submit1 "   value= "ok ">
</form>
</body>

upload.asp
<%@   CODEPAGE=65001   %>
<%   Response.Charset= "UTF-8 "   %>  
<!--#include   FILE= "upload.inc "-->
<HTML>
<HEAD>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=utf-8 "   />
</head>
<body>
<%
set   upload=new   upload_5xSoft
for   each   formName   in   upload.form
        set   form_str=upload.form(formName)
        select   case   form_str.FormName
                case   "uname "
                        uname=   form_str.Formvalue
        end   select
next
response.write   uname
%>
</body>
</html>

upload.inc
就是网上常用的
<SCRIPT   RUNAT=SERVER   LANGUAGE=VBSCRIPT>
dim   upfile_5xSoft_Stream

Class   upload_5xSoft
   
dim   Form,File
   
Private   Sub   Class_Initialize  
dim   iStart,iFileNameStart,iFileNameEnd,iEnd,vbEnter,iFormStart,iFormEnd,theFile
dim   strDiv,mFormName,mFormValue,mFileName,mFileSize,mFilePath,iDivLen,mStr,theForm
if   Request.TotalBytes <1   then   Exit   Sub
set   Form=CreateObject( "Scripting.Dictionary ")
set   File=CreateObject( "Scripting.Dictionary ")
set   upfile_5xSoft_Stream=CreateObject( "Adodb.Stream ")
upfile_5xSoft_Stream.mode=3
upfile_5xSoft_Stream.type=1
upfile_5xSoft_Stream.open
upfile_5xSoft_Stream.write   Request.BinaryRead(Request.TotalBytes)

vbEnter=Chr(13)&Chr(10)
iDivLen=inString(1,vbEnter)+1
strDiv=subString(1,iDivLen)
iFormStart=iDivLen
iFormEnd=inString(iformStart,strDiv)-1
while   iFormStart   <   iFormEnd
    iStart=inString(iFormStart, "name= " " ")
    iEnd=inString(iStart+6, " " " ")
    mFormName=subString(iStart+6,iEnd-iStart-6)
    iFileNameStart=inString(iEnd+1, "filename= " " ")

    if   iFileNameStart> 0   and   iFileNameStart <iFormEnd   then
      iFileNameEnd=inString(iFileNameStart+10, " " " ")
      mFileName=subString(iFileNameStart+10,iFileNameEnd-iFileNameStart-10)
      iStart=inString(iFileNameEnd+1,vbEnter&vbEnter)
      iEnd=inString(iStart+4,vbEnter&