使用utf-8文件名进行纯ASP上传

时间:2014-03-27 10:48:54

标签: utf-8 asp-classic upload filenames

我已经在经典asp中创建了一个上传页面,只要文件名不是utf-8字符,它就能正常工作。我在页面中添加了字符集,表单接受utf-8字符,但我的文件保存为Доклад Региона.pdf错误应为Доклад Региона.pdf

我不知道我还能做什么,或者是" Pure-ASP文件上传"不支持utf-8字符。 有人怎么解决它?

我的asp页面看起来像这样

<% 
Response.CodePage = 65001 
Response.CharSet = "utf-8" 

'Create upload form
'Using Huge-ASP file upload
'Dim Form: Set Form = Server.CreateObject("ScriptUtils.ASPForm")
'Using Pure-ASP file upload
Dim Form: Set Form = New ASPForm %><!--#INCLUDE FILE="upload2.asp"--><% 
dim File


DestinationPath = Server.mapPath("Files")
If Form.State = 0 Then 'Completted
    For Each File In Form.Files.Items
        If Len(File.FileName) > 0 Then
            Form.Files.Save DestinationPath 
        End If
    Next
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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Language" content="en"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Project Site</title>
<link id="ss__cs" rel="stylesheet" href="CSS/stylesheet.css" type="text/css"/>
</head>
<body style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; padding: 0;" >

<form method="POST" id="myform" ENCTYPE="multipart/form-data" acceptcharset="UTF-8">
<table>
    <tr>
        <td>File</td>
        <td><input type="file" id="File1" name="File1" class="defaultfont"></td>    
    </tr>
    <tr height="10">

    </tr>
    <tr>
        <td></td>
        <td><input Value="Cancel" Type="button" class="defaultfont" onclick="window.close()">&nbsp;&nbsp;&nbsp;<input Value="Upload file" Type="submit" class="defaultfont" ></td>    
    </tr>
</table>

</Form>

</body>
</html>

1 个答案:

答案 0 :(得分:1)

尝试添加

If Form.State = 0 Then 'Completted
  'Add this line to set the character set based on the response.
  Form.CharSet = Response.CharSet

有关详细信息,请参阅Upload - use unicode (utf-8) character set for request/response data