1: <script language="vbscript" type="text/vbscript">
2:
3: 'fileName can be any file including full path on your local drive
4:
5: Function PostImageData(ByVal fileName)
6: Const fsDoOverwrite = true ' Overwrite file with base64 code
7: Const fsAsASCII = false ' Create base64 code file as ASCII file
8: Const adTypeBinary = 1 ' Binary file is encoded
9: Dim objXML,objDocElem
10: Dim objStream, objFSO
11:
12: Set objXML = CreateObject("MSXml2.DOMDocument")
13: Set objDocElem = objXML.createElement("Base64Data")
14:
15: On Error Resume Next
16: Set objFSO = CreateObject("Scripting.FileSystemObject")
17: Set objStream = CreateObject("ADODB.Stream")
18:
19: If Err.Number = 0 Then
20: If objFSO.FileExists(fileName) Then
21: objStream.Type = adTypeBinary
22: objStream.Open()
23: objStream.LoadFromFile(fileName)
24: objDocElem.dataType = "bin.base64"
25: objDocElem.nodeTypedValue = objStream.Read()
26: frmPageName.txtBase64Data.value = objDocElem.text
27: objStream.Close()
28: 'objFSO.DeleteFile fileName,true 'Delete the Image file if needed
29: Else
30: MsgBox("Could not find Image file " & fileName)
31: End If
32: Else
33: MsgBox("Your Browser Secuirty Settings currently do not allow image file reading.")
34: End If
35:
36: Set objXML = Nothing
37: Set objDocElem = Nothing
38: Set objStream = Nothing
39: Set objFSO = Nothing
40: End function
41:
42: </script>