纯ASP上传使用UTF-8的文件名 [英] Pure ASP upload with utf-8 filenames
问题描述
我已在传统的ASP上传一个页面,它工作正常,只要文件名不是UTF-8字符。我加入的charset直到页面和形式接受UTF-8字符,但我的文件保存为 DоклD°D'ÐÐμгиона的.pdf
的bug应ДокладРегиона.pdf
我不知道是否有什么更多的,我可以做什么或它是纯ASP文件上传不支持UTF-8字符。
有谁如何解决它?
我的ASP页面看起来像这样
<%
响应。codePAGE = 65001
Response.Charset的=UTF-8创建上传表单
使用巨大-ASP文件上传
昏暗的形式:设置表=的Server.CreateObject(ScriptUtils.ASPForm)
'使用纯ASP文件上传
昏暗的形式:!设置表=新ASPForm%GT;< - #包含文件=upload2.asp - ><%
昏暗的文件
=的DestinationPath使用Server.Mappath(文件)
如果Form.State = 0,则'Completted
对于每个文件在Form.Files.Items
如果len(File.FileName)GT; 0,则
Form.Files.Save的DestinationPath
万一
下一个
万一
%GT;
< DOCTYPE HTML PUBLIC - // W3C // DTD XHTML 1.0过渡// ENHTTP:/ /www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
< HTML的xmlns =http://www.w3.org/1999/xhtmlXML:LANG =ENLANG =ENGT&;
< HEAD>
< META HTTP-EQUIV =内容语言CONTENT =EN/>
< META HTTP-EQUIV =Content-Type的CONTENT =text / html的;字符集= UTF-8/>
<标题>项目选址和LT; /标题>
<链路ID =ss__cs的rel =stylesheet属性HREF =CSS / stylesheet.css中类型=文/ CSS/>
< /头>
<车身风格=的margin-top:0像素;保证金底:0像素;保证金左:0像素;保证金右:0像素;填充:0; ><形式方法=POSTID =MyForm的ENCTYPE =的multipart / form-data的acceptcharset =UTF-8>
<表>
&所述; TR>
< TD>文件< / TD>
< TD><输入类型=文件ID =文件1NAME =文件1级=defaultfont>< / TD>
< / TR>
&所述; TR高度=10> < / TR>
&所述; TR>
< TD>< / TD>
< TD><输入值=取消类型=按钮级=defaultfont的onclick =window.close()的>&安培; NBSP;&安培; NBSP;&安培; NBSP;<输入值= 上传文件类型=提交级=defaultfont>< / TD>
< / TR>
< /表>< /表及GT;< /身体GT;
< / HTML>
尝试添加
如果Form.State = 0,则'Completted
添加此行来设置基于响应的字符集。
Form.CharSet = Response.Charset的
有关详细信息,请参见上传 - 采用UNI code(UTF-8)字符对于请求/响应数据设定。
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()"> <input Value="Upload file" Type="submit" class="defaultfont" ></td>
</tr>
</table>
</Form>
</body>
</html>
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 .
这篇关于纯ASP上传使用UTF-8的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!