相关代码:
set NextFile = objUpload.GetNextFile
objUpload.DirectoryCreate SaveFolderName
if not(NextFile is nothing) then
uname=objUpload.GetUniqueName
uname=mid(uname,instr(uname,"{")+1)
uname=left(uname,instr(uname,"}")-1)
filename=mid(NextFile.FileName,instr(NextFile.FileName,"_")+1)
NextFile.FileName=uname &"." & objupload.GetFileExt(NextFile.FileName)
NextFileName=NextFile.FileName
do until NextFile is nothing
NextFile.Save SaveFolderName
set NextFile = nothing
set NextFile = objUpload.GetNextFile
if Err <> 0 then
call CheckErr
exit do
end if
loop
10 个解决方案
#1
既然转化了,还保留中文名字有什么意义呢,中文文件名字会导致错误
#2
就是想保存的时候,文件名可读性好。要不一大堆诸如C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm的名字也不知道是什么阿!
#3
加一个字段注解啊
#4
嗯,有理
加一个字段保存原中文文件名
加一个字段保存原中文文件名
#5
我加了,可下载的时候“选择另存为”,出现的文件名还是C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm,我要是再手动改名,那就很麻烦了,我的意思是不管用什么方法,只要我保存文件时,自动存为中文名。
#6
Response.ContentType = "APPLICATION/OCTET-STREAM"
Response.AddHeader "Content-Disposition","attachment;filename=中文名.chm"
http://www.csdn.net/Develop/read_article.asp?id=13004
Response.AddHeader "Content-Disposition","attachment;filename=中文名.chm"
http://www.csdn.net/Develop/read_article.asp?id=13004
#7
孟子兄,这篇文章里的方法在IE的有些版本中会有Bug,有没有解决方法?
#8
孟子兄弟,谢谢~~~~~~~~
#9
不好意思,又有新的问题了,我的做法是在a.asp中需要下载文件“注册方法.chm”的地方用连接:
<a href="test.asp" target="_blank">存为中文名</a>
它的存储路径就在跟目录下,真实的文件名为:C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm ;
test.asp中的程序为:
<%
Response.buffer = TRUE
Response.ContentType = "APPLICATION/OCTET-STREAM"
Response.AddHeader "Content-Disposition","attachment;filename="注册方法.chm"
Response.write "<div style='background-color:navy;color:#FFFFFF'>测试</div>"
Response.End
%>
那我怎么做才能真正的下载 C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm 这个文件呢。
说明:我按照上边的方法试验,存储时文件名是为 “注册方法.chm” ,但内容确是 test.asp 的内容,这肯定不行的,我想要下载的文件是 C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm ,朋友们有没有什么好的方法???
<a href="test.asp" target="_blank">存为中文名</a>
它的存储路径就在跟目录下,真实的文件名为:C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm ;
test.asp中的程序为:
<%
Response.buffer = TRUE
Response.ContentType = "APPLICATION/OCTET-STREAM"
Response.AddHeader "Content-Disposition","attachment;filename="注册方法.chm"
Response.write "<div style='background-color:navy;color:#FFFFFF'>测试</div>"
Response.End
%>
那我怎么做才能真正的下载 C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm 这个文件呢。
说明:我按照上边的方法试验,存储时文件名是为 “注册方法.chm” ,但内容确是 test.asp 的内容,这肯定不行的,我想要下载的文件是 C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm ,朋友们有没有什么好的方法???
#10
<%
'***********************************************
' 强制下载已知类型的文件
'***********************************************
Const ForReading=1
Const TristateTrue=-1 'Unicode
Const FILE_TRANSFER_SIZE=16384 '16k
'Use the following line for IIS4/PWS - this is the default for IIS5
Response.Buffer = True
Function TransferFile(path, mimeType, filename)
Dim objFileSystem, objFile, objStream
Dim char
Dim sent
send=0
TransferFile = True
Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.GetFile(Path)
Set objStream = objFile.OpenAsTextStream(ForReading, TristateTrue)
Response.AddHeader "content-type", mimeType
response.AddHeader "Content-Disposition","attachment;filename="&filename
Response.AddHeader "content-length", objFile.Size
Do While Not objStream.AtEndOfStream
char = objStream.Read(1)
Response.BinaryWrite(char)
sent = sent + 1
If (sent MOD FILE_TRANSFER_SIZE) = 0 Then
Response.Flush
If Not Response.IsClientConnected Then
TransferFile = False
Exit Do
End If
End If
Loop
Response.Flush
If Not Response.IsClientConnected Then TransferFile = False
objStream.Close
Set objStream = Nothing
Set objFileSystem = Nothing
End Function
Dim path, mimeType, sucess
'Server.MapPath(path)
path = "C:\C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm"
mimeType = "application/x-msdownload"
sucess = TransferFile(path, mimeType,"中文名.chm")
Response.End
%>
'***********************************************
' 强制下载已知类型的文件
'***********************************************
Const ForReading=1
Const TristateTrue=-1 'Unicode
Const FILE_TRANSFER_SIZE=16384 '16k
'Use the following line for IIS4/PWS - this is the default for IIS5
Response.Buffer = True
Function TransferFile(path, mimeType, filename)
Dim objFileSystem, objFile, objStream
Dim char
Dim sent
send=0
TransferFile = True
Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.GetFile(Path)
Set objStream = objFile.OpenAsTextStream(ForReading, TristateTrue)
Response.AddHeader "content-type", mimeType
response.AddHeader "Content-Disposition","attachment;filename="&filename
Response.AddHeader "content-length", objFile.Size
Do While Not objStream.AtEndOfStream
char = objStream.Read(1)
Response.BinaryWrite(char)
sent = sent + 1
If (sent MOD FILE_TRANSFER_SIZE) = 0 Then
Response.Flush
If Not Response.IsClientConnected Then
TransferFile = False
Exit Do
End If
End If
Loop
Response.Flush
If Not Response.IsClientConnected Then TransferFile = False
objStream.Close
Set objStream = Nothing
Set objFileSystem = Nothing
End Function
Dim path, mimeType, sucess
'Server.MapPath(path)
path = "C:\C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm"
mimeType = "application/x-msdownload"
sucess = TransferFile(path, mimeType,"中文名.chm")
Response.End
%>
#1
既然转化了,还保留中文名字有什么意义呢,中文文件名字会导致错误
#2
就是想保存的时候,文件名可读性好。要不一大堆诸如C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm的名字也不知道是什么阿!
#3
加一个字段注解啊
#4
嗯,有理
加一个字段保存原中文文件名
加一个字段保存原中文文件名
#5
我加了,可下载的时候“选择另存为”,出现的文件名还是C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm,我要是再手动改名,那就很麻烦了,我的意思是不管用什么方法,只要我保存文件时,自动存为中文名。
#6
Response.ContentType = "APPLICATION/OCTET-STREAM"
Response.AddHeader "Content-Disposition","attachment;filename=中文名.chm"
http://www.csdn.net/Develop/read_article.asp?id=13004
Response.AddHeader "Content-Disposition","attachment;filename=中文名.chm"
http://www.csdn.net/Develop/read_article.asp?id=13004
#7
孟子兄,这篇文章里的方法在IE的有些版本中会有Bug,有没有解决方法?
#8
孟子兄弟,谢谢~~~~~~~~
#9
不好意思,又有新的问题了,我的做法是在a.asp中需要下载文件“注册方法.chm”的地方用连接:
<a href="test.asp" target="_blank">存为中文名</a>
它的存储路径就在跟目录下,真实的文件名为:C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm ;
test.asp中的程序为:
<%
Response.buffer = TRUE
Response.ContentType = "APPLICATION/OCTET-STREAM"
Response.AddHeader "Content-Disposition","attachment;filename="注册方法.chm"
Response.write "<div style='background-color:navy;color:#FFFFFF'>测试</div>"
Response.End
%>
那我怎么做才能真正的下载 C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm 这个文件呢。
说明:我按照上边的方法试验,存储时文件名是为 “注册方法.chm” ,但内容确是 test.asp 的内容,这肯定不行的,我想要下载的文件是 C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm ,朋友们有没有什么好的方法???
<a href="test.asp" target="_blank">存为中文名</a>
它的存储路径就在跟目录下,真实的文件名为:C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm ;
test.asp中的程序为:
<%
Response.buffer = TRUE
Response.ContentType = "APPLICATION/OCTET-STREAM"
Response.AddHeader "Content-Disposition","attachment;filename="注册方法.chm"
Response.write "<div style='background-color:navy;color:#FFFFFF'>测试</div>"
Response.End
%>
那我怎么做才能真正的下载 C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm 这个文件呢。
说明:我按照上边的方法试验,存储时文件名是为 “注册方法.chm” ,但内容确是 test.asp 的内容,这肯定不行的,我想要下载的文件是 C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm ,朋友们有没有什么好的方法???
#10
<%
'***********************************************
' 强制下载已知类型的文件
'***********************************************
Const ForReading=1
Const TristateTrue=-1 'Unicode
Const FILE_TRANSFER_SIZE=16384 '16k
'Use the following line for IIS4/PWS - this is the default for IIS5
Response.Buffer = True
Function TransferFile(path, mimeType, filename)
Dim objFileSystem, objFile, objStream
Dim char
Dim sent
send=0
TransferFile = True
Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.GetFile(Path)
Set objStream = objFile.OpenAsTextStream(ForReading, TristateTrue)
Response.AddHeader "content-type", mimeType
response.AddHeader "Content-Disposition","attachment;filename="&filename
Response.AddHeader "content-length", objFile.Size
Do While Not objStream.AtEndOfStream
char = objStream.Read(1)
Response.BinaryWrite(char)
sent = sent + 1
If (sent MOD FILE_TRANSFER_SIZE) = 0 Then
Response.Flush
If Not Response.IsClientConnected Then
TransferFile = False
Exit Do
End If
End If
Loop
Response.Flush
If Not Response.IsClientConnected Then TransferFile = False
objStream.Close
Set objStream = Nothing
Set objFileSystem = Nothing
End Function
Dim path, mimeType, sucess
'Server.MapPath(path)
path = "C:\C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm"
mimeType = "application/x-msdownload"
sucess = TransferFile(path, mimeType,"中文名.chm")
Response.End
%>
'***********************************************
' 强制下载已知类型的文件
'***********************************************
Const ForReading=1
Const TristateTrue=-1 'Unicode
Const FILE_TRANSFER_SIZE=16384 '16k
'Use the following line for IIS4/PWS - this is the default for IIS5
Response.Buffer = True
Function TransferFile(path, mimeType, filename)
Dim objFileSystem, objFile, objStream
Dim char
Dim sent
send=0
TransferFile = True
Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.GetFile(Path)
Set objStream = objFile.OpenAsTextStream(ForReading, TristateTrue)
Response.AddHeader "content-type", mimeType
response.AddHeader "Content-Disposition","attachment;filename="&filename
Response.AddHeader "content-length", objFile.Size
Do While Not objStream.AtEndOfStream
char = objStream.Read(1)
Response.BinaryWrite(char)
sent = sent + 1
If (sent MOD FILE_TRANSFER_SIZE) = 0 Then
Response.Flush
If Not Response.IsClientConnected Then
TransferFile = False
Exit Do
End If
End If
Loop
Response.Flush
If Not Response.IsClientConnected Then TransferFile = False
objStream.Close
Set objStream = Nothing
Set objFileSystem = Nothing
End Function
Dim path, mimeType, sucess
'Server.MapPath(path)
path = "C:\C3789A93-C980-450E-9D8B-0E4444E5E9CA.chm"
mimeType = "application/x-msdownload"
sucess = TransferFile(path, mimeType,"中文名.chm")
Response.End
%>