%@language="vbscript" codepage="65001"%> <%'the codepage (!)%> <% dim Uploader, File, Path, First, Last, Text 'Get reference to ASPUploader: set Uploader = GetASPUploader 'Set the charset: Uploader.Charset = "utf-8" '(!) 'Empty string "" means to save file(s) to memory stream: Uploader.Destination = "" 'Set longer timeout for large files if needed: Server.ScriptTimeout = 900 'Enable error handling: on error resume next 'Start receiving and saving file: Uploader.Upload 'Check for errors: if Err then Response.Write Err.Source & ": " & Err.Description Response.End end if if Uploader.Files.Count = 0 then Response.Write "Please upload a file to test this example." Response.End end if 'Get reference to the uploaded file object: set File = Uploader.Files("File1") 'Save the file to disk if needed: Path = Server.MapPath("Upload") MakeDir Path File.Stream.Position = 0 File.Stream.Type = 1 'adTypeBinary = 1 File.Stream.SaveToFile Path & "\" & File.Name, 2 'adSaveCreateOverWrite = 2 '(You could save the file with a different name if needed) 'Check for errors: if Err then Response.Write Err.Source & ": " & Err.Description Response.End end if 'Read the file content: if File.Size > 20 then File.Stream.Position = 0 File.Stream.Type = 2 'adTypeText = 2 File.Stream.Charset = "us-ascii" 'Change us-ascii to the actual charset that you expect in the file to display the characters properly. 'Read the first 10 bytes: First = File.Stream.ReadText(10) 'Read the last 10 bytes: File.Stream.Position = File.Stream.Size - 10 Last = File.Stream.ReadText(10) else Response.Write "Please upload a larger file to test this example." Response.End end if '(The object referenced by File.Stream is ADO Stream object. See ADO documentation for complete reference of all its properties and methods.) 'Check for errors: if Err then Response.Write Err.Source & ": " & Err.Description Response.End end if Text = Uploader.Form("Text1") 'You can save the value of Text variable to database: 'MyRecordset("MyField") = Text 'Use the same codepage and charset when you retrieve it from the database to display in browser: 'Text = MyRecordset("MyField") 'Set the CodePage before sending any response: Response.CodePage = 65001 '(!) %>