VB Upload File - Chinese OS

Hi Guys,

Me trying to upload file using VB HTTP Post method. Can successfully upload the files when my client machine is English OS . However , the problem occurs when am trying to upload the files from Chinese OS. It seems that the file uploaded is getting corrupted and could not be opened in correct format. This is applicable for binary files. The text files could be uploaded successfully.
I have tried setting content-type, charset,codepage etc properties to assemble the body.

Can anyone help me ? Its urgent ....Hope to find some VB GURU in this group.HELP !

part of the code :

==========================

Sub uploadFile(a_strUserName As String, a_strUserPassword As String, a_strServerURL As String, a_strFilename As String, a_strFileTitle)

On Error GoTo err_uploadFile

Const HTTPREQUEST_PROXYSETTING_DEFAULT = 0
Const HTTPREQUEST_PROXYSETTING_PRECONFIG = 0
Const HTTPREQUEST_PROXYSETTING_DIRECT = 1
Const HTTPREQUEST_PROXYSETTING_PROXY = 2

Const HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0
Const HTTPREQUEST_SETCREDENTIALS_FOR_PROXY = 1

' WinHTTPRequest options
Const WinHttpRequestOption_UserAgentString = 0
Const WinHttpRequestOption_URL = 1
Const WinHttpRequestOption_URLCodePage = 2
Const WinHttpRequestOption_EscapePercentInURL = 3
Const WinHttpRequestOption_SslErrorIgnoreFlags = 4
Const WinHttpRequestOption_SelectCertificate = 5
Const WinHttpRequestOption_EnableRedirects = 6
Const WinHttpRequestOption_UrlEscapeDisable = 7
Const WinHttpRequestOption_UrlEscapeDisableQuery = 8
Const WinHttpRequestOption_SecureProtocols = 9
Const WinHttpRequestOption_EnableTracing = 10

Const SslErrorFlag_Ignore_All = 13056

Const HTTP_STATUS_PROXY_AUTH_REQ = 407
Const HTTP_STATUS_DENIED = 401
Const HTTP_STATUS_OK = 200

Dim strFile As String
Dim strURL As String
Dim strBody As String
Dim aPostBody() As Byte
Dim nFile As Integer

' Read the file from the hard disk
nFile = FreeFile
Open a_strFilename For Binary As #nFile
strFile = String(LOF(nFile), " ")
Get #nFile, , strFile
Close #nFile

''' Dim w_objWinHttpRequest As New WinHttp.WinHttpRequest
Dim w_strRequestURL As String
Dim w_strProxyURL As String

''' Set g_objWinHttpRequest = CreateObject("WinHttp.WinHttpRequest.5.1")

w_strProxyURL = getProxyURL()

If Len(w_strProxyURL) > 0 Then
g_objWinHttpRequest.SetProxy HTTPREQUEST_PROXYSETTING_PROXY, w_strProxyURL, getProxyByPassServerList()

End If

w_strRequestURL = a_strServerURL & JSP_FILE_UPLOAD

g_objWinHttpRequest.SetTimeouts 0, 0, 0, 0

g_objWinHttpRequest.Open "POST", w_strRequestURL, False

' Set the header < here i have tried setting the charset , codepage parameters too but of little use as on the server 'side the extraction of the zip file is not done according to the given encoding method.>
g_objWinHttpRequest.SetRequestHeader "Content-Type", "multipart/form-data; boundary=Xu02=$"

' Assemble the body
strBody = "--Xu02=$" & vbCrLf & _
"Content-Disposition: form-data; name=""TestFile""; filename=""" & a_strFileTitle & """" & vbCrLf & _
"Content-type: file" & vbCrLf & vbCrLf & _
strFile & vbCrLf & _
"--Xu02=$--"

' Because of binary zeros, post body has to convert to byte array
aPostBody = StrConv(strBody, vbFromUnicode, g_lngLocaleID) 'vbFromUnicode

WriteToLogFile ("strbody :" & strBody & " localeid: " & g_lngLocaleID)

g_objWinHttpRequest.Option(WinHttpRequestOption_EnableHttpsToHttpRedirects) = True

g_objWinHttpRequest.Option(WinHttpRequestOption_SelectCertificate) = True

g_objWinHttpRequest.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = SslErrorFlag_Ignore_All

g_objWinHttpRequest.SetClientCertificate "LOCAL_MACHINE\Other People"
g_objWinHttpRequest.Send aPostBody 'posts the body to JSP.

If g_objWinHttpRequest.Status = HTTP_STATUS_DENIED Then
g_objWinHttpRequest.SetCredentials a_strUserName, a_strUserPassword, HTTPREQUEST_SETCREDENTIALS_FOR_SERVER
g_objWinHttpRequest.Send aPostBody

End If

Exit Sub

err_uploadFile:

m_ErrorDesc = "err_uploadFile [ERROR] : " & err.Description
m_ErrorFlag = True
WriteToLogFile "err_uploadFile [ERROR] : " & err.Description

End Sub

==========================

Thanks in advance,
Ashish.0.

[5021 byte] By [AshishOjha] at [2007-12-30]
# 1

Hi Ashish,

This forum is for questions related to the Visual Basic 2005 PowerPack downloads. You will probably have better luck getting a quick answer if you post your question in the Visual Basic General section (http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=32&SiteID=1) .

Steve Hoag

Visual Basic PowerPacks

shoagMSFT at 2007-9-5 > top of Msdn Tech,Visual Basic,Visual Basic Power Packs...