473,406 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

HttpSendRequest always return false.

I am facing problem in HttpSendRequest() API(Developing OCX for Http Upload control.).It always return false.Any idea?I am posting my code:

Public Function UploadFileHTTP(ByVal localFileName As String, ByVal remoteFileName As String) As Integer
Dim nRet As Integer
Dim nFileHandle As Integer
Dim bData(BUFFER_SIZE - 1) As Byte
Dim leftoversize As Long
lWritten = 0
Dim blnSendRequest As Boolean
Dim remoteFileSize As Long
Dim sData As String
nFileHandle = FreeFile
hRequest = HttpOpenRequest(hConnect, "PUT", remoteFileName, "HTTP/1.0", vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
If hRequest = 0 Then
LastDllErrorInfo 'Call before calling any other dll function
If Not HttpErrorCode = 0 Then
Err.Raise HttpErrorCode, , HttpErrorString
End If
Exit Function
End If
sData = String(BUFFER_SIZE, 0)
blnSendRequest = HttpSendRequest(hRequest, vbNullString, 0, 0, 0)
HTTP_QUERY_CONTENT_LENGTH, sData, Len(sData))
'Read data from local buffer
Open localFileName For Binary Access Read As nFileHandle 'Open the source file (localFileName) for read access
nLOF = LOF(nFileHandle) 'Create a buffer that will hold the contents of the file
leftoversize = nLOF
If leftoversize <> 0 Then
Get nFileHandle, , bData 'Read the contents of the file into the buffer.

'Write to server
nRet = InternetWriteFile(hRequest, bData(0), Len(bData(0)), lWritten)
If nRet = 0 Then
LastDllErrorInfo 'Call before calling any other dll function
If Not HttpErrorCode = 0 Then
Err.Raise HttpErrorCode, , HttpErrorString
End If
Exit Function
End If
End If
InternetCloseHandle hRequest
InternetCloseHandle hConnect
InternetCloseHandle hInternet
End Function
Mar 25 '08 #1
0 1168

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mishi Abolghasem | last post by:
I'm trying to use this sequence of VB-API calls to post to a web-page where client certificate is required.( InternetOpen,InternetConnect,HttpOpenRequest,HttpSendRequest) And then InternetReadFile...
6
by: Tim::.. | last post by:
Can someone tell me why the value of my Boolean is always false! Even after I have declared that my variable iNews should equal TRUE it seems to remain false... Can some please explain why... ...
12
by: snow | last post by:
Hi All, I noticed if file path has a white space, for example "C:\my document \test.txt", the function File.Exists(filePath) always return false in release mode. How could I make this function...
0
by: comp.lang.php | last post by:
if (!function_exists('mime_content_type_fileinfo')) { /** * Will use {@link http://us2.php.net/fileinfo FileInfo} functions provided within {@link http://pecl.php.net PECL} bundle to return mime...
2
by: mlevit | last post by:
Hi, I've written my own JavaScript and used a couple of codes to set and get cookies from the net I found. When I set the cookie I can see it in my browser, it is set with the right value and...
0
by: sudhivns | last post by:
Hi, Is there any length limitation for the parameter LPCTSTR lpszObjectName, in HttpOpenRequest(). ?? I'm using some URL appended with lengthy string (>4KB) while using HttpSendRequest(). Does...
0
by: pskumaran | last post by:
Hi All, I am sending optional data to the webserver thru httpsendrequest. I am getting the status code "200 - Ok", which means the request is successful. Now, I want to read back the same...
0
by: Swan | last post by:
Can anyone plz tell me what is the limitation(size) of HttpSendRequest api to upload the file? I mean how big file it can upload? Thank you!
7
Haitashi
by: Haitashi | last post by:
I have a form that calls a function using the onClick event in the submit button. I would like this function to return false if the username is taken. The the original function, which I've tested,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.