经典 ASP + Motobit 纯 ASP 上传 + UTF-8 字符集

2022-01-01 00:00:00 utf-8 upload asp-classic mysql vbscript

去用utf-8的mysql数据库和我所有的页面后,检查编码并include

After going to use the mysql database in utf-8 and all my pages, check the coding and include

@ Language = VBScript CodePage = 65001

在HTML页面中,包括:

In the HTML page, including:

meta charset = "utf-8"

一切都非常顺利,直到我不得不更改我的上传系统.现在,我正在使用 Pure Asp Upload,它用于发送图像,这很棒,但我需要您的帮助,因为其他文本字段太疯狂了.

Everything was going wonderfully well until I have to change my upload system.   Now, I'm using the Pure Asp Upload, which for sending images, it's great, but I need your help, because the other text fields, are crazy.

我写了一个很简单的代码,只有一个File域和一个文本域,只是为了举例,他拿域后不久就给出了一个Response.End()只是想看看会发生什么,但是过了几天没有成功,过来帮忙.

I made a very simple code, with just a File field and a text field, just to exemplify, and give a Response.End () shortly after he takes the field just to try to see what happens, but after several days without success, come help.

纯Asp上传版本为2.06

Pure Asp Upload version is 2.06

<%@ Language=VBScript CodePage=65001%>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
%>
<!--#include file="../includes/pure-upload.asp"-->
<% Session.Timeout = 60 %>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
%>
<%
sAction = Request.querystring("a_edit")

If sAction = "" Or IsNull(sAction) Then
    sAction = "I" ' Display Record
else
    Dim fupload: Set fupload = New ASPForm

    Server.ScriptTimeout = 2000
    fupload.SizeLimit = 4*1000000 'limit of size per whole form
    Const fsCompletted  = 0

    If fupload.State = fsCompletted Then 'Completted

    fupload.CharSet = Response.CharSet
    x_jogadorID = fupload("x_jogadorID")
    x_jogadorNome = fupload.Item("x_jogadorNome")

    meukarma = fupload.CharSet
    response.write x_jogadorNome & "-" & meukarma
    response.End()

    ElseIf fupload.State > 10 then
      Const fsSizeLimit = &HD
      Select case fupload.State
        case fsSizeLimit
            Session(ewSessionMessage) = "<br><Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font><br>"
            Session(ewSessionMessageTipo) = "error"
        case else 
            Session(ewSessionMessage) = "<Font Color=red>Erro no Formulário." & Form.State & "</Font><br>"
            Session(ewSessionMessageTipo) = "error"
      end Select
    End If 'Form.State = 0 then
End If 

%>
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>teste</title>
</head>

<body>
<form name="fjogadoredit" id="fjogadoredit" action="teste.asp?a_edit=U" class="form-horizontal" method="post" enctype="multipart/form-data"  onSubmit="return EW_checkMyForm(this);" >
<input type="text" name="x_jogadorNome" id="x_jogadorNome" class="input-xlarge" maxlength="50" value="<%= Server.HTMLEncode(x_jogadorNome&"") %>">
<input type="file" id="x_jogadorFotoRosto" name="x_jogadorFotoRosto"  class="default">
</form>
</body>
</html>

我是注册考试的名字是Amésio,更改为:

The name I'm a registered test is Amésio, changed by:

amnésio

如果我早在第二行就把块放在下面,Amésio 的结果是

If I put the block below as early as the second line, the result for Amésio is

amnésio

<%
Response.AddHeader "Content-Type", "text/html; charset=utf-8"
response.Charset="utf-8"
%>

有人设法以这种方式使用此组件,或者设法解决了,就像它所做的那样?

Someone managed to use this component in this way, or managed to solve, as it did?

推荐答案

在阅读本文之前,我建议您快速浏览一下这个答案

Before reading this I suggest taking a quick look at this answer

了解 IIS 如何处理 ASP 编码

对于您的具体问题,我认为这归结为未指定

AS for your specific problem I think it's down to not specifying

Response.CodePage = 65001

明确地假设它是 65001 而不检查它,然后再将 ASPForm.CharSet 属性分配给它.

explicitly and assuming it's 65001 without checking it before assigning the ASPForm.CharSet property to it.

试试这个

<%@ Language=VBScript CodePage=65001%>
<%
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate"
%>
<!--#include file="../includes/pure-upload.asp"-->
<%
Session.Timeout = 60

sAction = Request.querystring("a_edit")

'Make sure both IIS and the Browser know how to process the page / response
Response.CodePage = 65001
Response.CharSet = "UTF-8"

If sAction = "" Or IsNull(sAction) Then
    sAction = "I" ' Display Record
else
    Dim fupload: Set fupload = New ASPForm

    Server.ScriptTimeout = 2000
    fupload.SizeLimit = 4*1000000 'limit of size per whole form
    Const fsCompletted  = 0

    If fupload.State = fsCompletted Then 'Completted

    fupload.CharSet = Response.CharSet
    x_jogadorID = fupload("x_jogadorID")
    x_jogadorNome = fupload.Item("x_jogadorNome")

    meukarma = fupload.CharSet
    response.write x_jogadorNome & "-" & meukarma

    ElseIf fupload.State > 10 then
      Const fsSizeLimit = &HD
      Select case fupload.State
        case fsSizeLimit
            Session(ewSessionMessage) = "<br><Font Color=red>Source form size (" & Form.TotalBytes & "B) exceeds form limit (" & Form.SizeLimit & "B)</Font><br>"
            Session(ewSessionMessageTipo) = "error"
        case else 
            Session(ewSessionMessage) = "<Font Color=red>Erro no Formulário." & Form.State & "</Font><br>"
            Session(ewSessionMessageTipo) = "error"
      end Select
    End If 'Form.State = 0 then
End If 

%>

<!doctype html>
<html>
<head>
<title>teste</title>
</head>

<body>
<form name="fjogadoredit" id="fjogadoredit" action="teste.asp?a_edit=U" class="form-horizontal" method="post" enctype="multipart/form-data"  onSubmit="return EW_checkMyForm(this);" >
<input type="text" name="x_jogadorNome" id="x_jogadorNome" class="input-xlarge" maxlength="50" value="<%= x_jogadorNome & "" %>">
<input type="file" id="x_jogadorFotoRosto" name="x_jogadorFotoRosto"  class="default">
</form>
</body>
</html>

相关文章