Pure ASP upload with utf-8 filenames

2019-02-27 10:56发布

I'm have made a upload page in classic asp and it works fine, as long as the filenames are not in utf-8 characters. I have added charset til the page and the form accepts utf-8 characters but my files are saved as Доклад Региона.pdf bug should be Доклад Региона.pdf

I don't know if there is anything more I can do or it is the "Pure-ASP file upload" that does not support utf-8 characters. Does anyone how to fix it?

My asp page looks like this

<% 
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条回答
smile是对你的礼貌
2楼-- · 2019-02-27 11:53

Try adding

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

For more information see Upload - use unicode (utf-8) character set for request/response data .

查看更多
登录 后发表回答