Starting with version 3.0, AspUpload is capable of converting
UTF-8 encoded text fields and file names back into Unicode strings.
If you anticipate using Unicode characters in text data or the names
of files you are uploading, you should instruct your browser
to POST all the information in the UTF-8 format. This is done by including the
following tag in the header of your page:
<HEAD>
...
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
On the AspUpload side, you must enable UTF-8 translation by setting the property
Upload.CodePage to 65001 (a Win32-defined value for CP_UTF8):
<%
Set Upload = Server.CreateObject("Persits.Upload")
Upload.CodePage = 65001
...
Upload.Save "c:\upload"
%>
|
The Upload.CodePage property can also be set to valid code page values such as 1251 (Cyrillic),
1255 (Hebrew), 1256 (Arabic), etc. Every time the CodePage property
is set, AspUpload will attempt to translate the text data
and file names into Unicode using the specified code page
by invoking the Win32 function MultiByteToWideChar.
The code samples unicode.asp and unicode_upload.asp
demonstrate AspUpload's Unicode support. Both files are shown here:
unicode.asp
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<h3>File and Text Items</h3>
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="unicode_upload.asp">
File 1:<INPUT TYPE=FILE NAME="FILE1"><BR>
Description 1:<INPUT TYPE=TEXT NAME="DESCR1"><BR>
<INPUT TYPE=SUBMIT VALUE="Upload!">
</FORM>
</BODY>
</HTML>
|
unicode_upload.asp
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>
<BODY>
<%
Set Upload = Server.CreateObject("Persits.Upload")
' Enable UTF-8 translation
Upload.CodePage = 65001
Upload.Save "c:\upload"
%>
Files:<BR>
<%
For Each File in Upload.Files
Response.Write File.Name & "= " & Server.HTMLEncode(File.Path) & " (" & File.Size &" bytes)<BR>"
Next
%>
<P>
Other items:<BR>
<%
For Each Item in Upload.Form
Response.Write Item.Name & "= " & Server.HTMLEncode(Item.Value) & "<BR>"
Next
%>
</BODY>
</HTML>
|
Note that this script uses Server.HTMLEncode on file names and text items.
This converts Unicode strings to a format understandable by
a browser, such as Персиц.
Click the link below to run this code sample:
http://localhost/aspupload/08_unicode/unicode.asp