<%@ Language=VBScript %> <% Option Explicit %> <% Response.Buffer = TRUE %> <% '------------------------------------------------------------------------- ' File Upload Template Example code ' Copyright (c) Microsoft Corporation. All rights reserved. '--------------------------------------------------------------- %> <% Dim bIsPost Dim F_FileName Server.ScriptTimeout = 3600 bIsPost = CInt(Request.QueryString("IsPost")) If bIsPost Then ' ' Perform file post processing. ' OnPostFile() Else ' ' Perform first time processing. File is not being posted ' during first time processing. ' OnFirstTime() End If Function OnFirstTime() WriteLine("") WriteLine("") WriteLine("") Call EmitFileSelectionForm() WriteLine("") WriteLine("") End Function Function OnPostFile() Dim sFileName Dim sUploadPath Dim iFileSize WriteLine("") WriteLine("") WriteLine("") Call EmitFileSelectionForm() WriteLine("
") If ( Post_UploadFile(sFileName, iFileSize) ) Then sUploadPath = Post_GetUploadPath() WriteLine("") WriteLine("") WriteLine("") WriteLine("") WriteLine("
") WriteLine("You selected file: "+ Server.HTMLEncode(sUploadPath + sFileName)) WriteLine("
") Else sFileName = "" End If WriteLine("
") WriteLine("" ) WriteLine("" ) WriteLine("" ) WriteLine("
") WriteLine("") WriteLine("") End Function Function Post_UploadFile(ByRef sFileName, ByRef iFileSize) Post_UploadFile = TRUE Err.Clear On Error Resume Next Dim oFileUpload Set oFileUpload = Server.CreateObject("Microsoft.FileUpload") If ( Err.Number <> 0 ) Then Post_UploadFile = FALSE Set oFileUpload = nothing SA_TraceOut "TEMPLATE_FILE_POST", "Error posting file: " + CStr(Hex(Err.Number)) WriteLine("
") WriteLine("File upload did not complete, unexpected error during upload.") WriteLine("
") WriteLine("Error code: " + CStr(Hex(Err.Number)) + " " + CStr(Err.Description)) WriteLine("
") Exit Function End If sFileName = oFileUpload.FileName If ( Err.Number <> 0 ) Then Post_UploadFile = FALSE Set oFileUpload = nothing SA_TraceOut "TEMPLATE_FILE_POST", "Unexpected error getting filename, error: " + CStr(Hex(Err.Number)) WriteLine("
") WriteLine("File upload did not complete, unable to query file name.") WriteLine("
") WriteLine("Error code: " + CStr(Hex(Err.Number)) + " " + CStr(Err.Description)) WriteLine("
") Exit Function End If iFileSize = oFileUpload.FileSize If ( Err.Number <> 0 ) Then Post_UploadFile = FALSE Set oFileUpload = nothing SA_TraceOut "TEMPLATE_FILE_POST", "Unexpected error getting file size, error: " + CStr(Hex(Err.Number)) WriteLine("
") WriteLine("File upload did not complete, unable to query file size.") WriteLine("
") WriteLine("Error code: " + CStr(Hex(Err.Number)) + " " + CStr(Err.Description)) WriteLine("
") Exit Function End If Set oFileUpload = nothing End Function Function EmitFileSelectionForm() WriteLine("
") WriteLine("") WriteLine("") WriteLine("") WriteLine("") WriteLine("
") End Function Function Post_GetUploadPath() on error resume next Dim objRegistry Set objRegistry = RegConnection() Post_GetUploadPath = GetRegKeyValue( objRegistry, _ "SOFTWARE\Microsoft\ServerAppliance\SoftwareUpdate", _ "UploadFileDirectory", _ CONST_STRING ) If ( Len(Trim(Post_GetUploadPath)) <= 0 ) Then SA_TraceOut "SW_UPDATE", "UploadFileDirectory registry entry missing" Post_GetUploadPath = "Z:\OS_DATA\Software Update" End If if ( Right(Post_GetUploadPath,1) <> "\") Then Post_GetUploadPath = Post_GetUploadPath + "\" End If Set objRegistry = nothing End Function Function WriteLine(ByVal sLine) Response.Write(sLine+vbCrLf) End Function %>