<> wrote in message
news:...
> Hey Peeps,
>
> Ok here is my situation.. I have a Java applet which allows the user to
select files and upload them to the server. The
> applet converts the file to Base64 and then POSTS the data to an ASP page.
>
> The ASP code I have is:
>
> <%
> Base64Chars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz0123456789+/"
>
> Public Function Base64Decode(sBase64)
> For i = 1 To Len(sBase64) Step 4
> w1 = FindPos(Mid(sBase64, i, 1))
> w2 = FindPos(Mid(sBase64, i + 1, 1))
> w3 = FindPos(Mid(sBase64, i + 2, 1))
> w4 = FindPos(Mid(sBase64, i + 3, 1))
> If (w2 >= 0) Then ByteArray = ByteArray & chrB((w1 * 4 + Int(w2 / 16)) And
255)
> If (w3 >= 0) Then ByteArray = ByteArray & chrB((w2 * 16 + Int(w3 / 4)) And
255)
> If (w4 >= 0) Then ByteArray = ByteArray & chrB((w3 * 64 + w4) And 255)
> Next
> Base64Decode = ByteArray
> End Function
>
> Private Function FindPos(sChar)
> If (Len(sChar) = 0) Then
> FindPos = -1
> Else
> FindPos = InStr(Base64Chars, sChar) - 1
> End If
> End Function
>
>
> Set oStream = Server.CreateObject("ADODB.Stream")
> oStream.Type = 1
> oStream.Open
> oStream.Write Base64Decode(Request.Form("file"))
> oStream .SaveToFile "c:\file.dat"
> oStream.Close()
> Set oStream = Nothing
> %>
>
> I am receving the following error:
>
> ADODB.Stream error '800a0bb9'
>
> Arguments are of the wrong type, are out of acceptable range, or are in
conflict with one another.
>
> /upload/upload.asp, line 29
>
> Any ideas?? This is all new to me.. any help would be much appreciated!!
>
> Thanks in advance!
>
> AJB
>
Try it without oStream to see what you get:
WScript.Echo Base64Decode(Request.Form("file"))
Here's an alternative:
Encode and Decode Base64 Files
http://www.fourmilab.ch/webtools/base64/
Option Explicit
Dim objWSS
Set objWSS = WScript.CreateObject("WScript.Shell")
objWSS.Run "%comspec% /C base64.exe -d encoded.txt decoded.txt", 1, True
Set objWSS = Nothing