I am using vb script to upload a file to the server. The problem I'm having is that when I set the file to ASCII format like this...
Set oFile = oFS.CreateTextFile(sPath & FileName, True, False)
I get an error when the sub is called that says
Invalid procedure call or argument
but if I set the file to unicode
Set oFile = oFS.CreateTextFile(sPath & FileName, True, True)
it uploads successfully but will not open because of the incorrect encoding. The line that produces the error is this one if format is ASCII is this one
oFile.Write BinaryToString(FileData)
where oFile
is the ASCII file I had created above
Here is the source code that produces the error. It's an upload function I got off the net..
Public Sub SaveToDisk(sPath)
Dim oFS, oFile
Dim nIndex
If sPath = "" Or FileName = "" Then Exit Sub
If Mid(sPath, Len(sPath)) <> "\" Then sPath = sPath & "\"
Set oFS = Server.CreateObject("Scripting.FileSystemObject")
If Not oFS.FolderExists(sPath) Then Exit Sub
Set oFile = oFS.CreateTextFile(sPath & FileName, True, False)
oFile.Write BinaryToString(FileData)
oFile.Close
End Sub
Function BinaryToString(Binary)
'Antonin Foller, http://www.motobit.com
'Optimized version of a simple BinaryToString algorithm.
Dim cl1, cl2, cl3, pl1, pl2, pl3
Dim L
cl1 = 1
cl2 = 1
cl3 = 1
L = LenB(Binary)
Do While cl1<=L
pl3 = pl3 & Chr(AscB(MidB(Binary,cl1,1)))
cl1 = cl1 + 1
cl3 = cl3 + 1
If cl3>300 Then
pl2 = pl2 & pl3
pl3 = ""
cl3 = 1
cl2 = cl2 + 1
If cl2>200 Then
pl1 = pl1 & pl2
pl2 = ""
cl2 = 1
End If
End If
Loop
BinaryToString = pl1 & pl2 & pl3
End Function
Could it be configurations on the server? If this makes any sense please help..