-
Http Upload
Can anyone get this to work?
I would like to be able to write on the server, with no files on the local machine.
Thanks in advance,
David.
I have been using modWinInet.BAS. Is that mainly for ftp?
Option Explicit
Const INTERNET_FLAG_NO_COOKIES = &H80000
Const INTERNET_FLAG_NO_CACHE_WRITE = &H4000000
Private Sub Command1_Click()
Call HttpUpload
End Sub
Private Sub HttpUpload()
Dim hInternet As Long
Dim lFlags As Long
Dim hRequest As Long
Dim hReq As Long
Dim szContent As String
Dim hConnect As Long
Dim MysendRequest As Integer
hInternet = InternetOpen(App.Title, INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
Debug.Print hInternet
hConnect = InternetConnect(hInternet, "http://www.yoururl.com/", 80, "Username", "Password", INTERNET_SERVICE_HTTP, 0, 0)
Debug.Print hConnect
lFlags = INTERNET_FLAG_NO_COOKIES
lFlags = lFlags Or INTERNET_FLAG_NO_CACHE_WRITE
hReq = HttpOpenRequest(hConnect, "PUT", "/page.htm", "HTTP/1.0", vbNullString, 0, lFlags, 0)
Debug.Print hReq
szContent = "Hello, World!"
MysendRequest = HttpSendRequest(hReq, vbNullString, 0, szContent, Len(szContent))
Debug.Print MysendRequest
InternetCloseHandle (hInternetSession)
End Sub:confused:
-
You can transfer files from local to server, you can't write direct to the server. Well, I guess you could, but then your VB program would have to store all the local file data internally.
Do you have any idea what this BAS module is doing?
If I were you I'd use the Inet control. It's much easier and wraps up the Inet API.
-
this may be of use (or maybe not)
chiefrb is right - if you have permission to run code the client & server then winet/wsocks is possible..
U need atleast a server componet to capture any upload..
you can do this even without client code (eg just html/javascript in the browser - if you change the format of a post to multipart/form-data - file contents are posted with INPUT TYPE=FILE tags...
this explains it better...
http://www.15seconds.com/Issue/990311.htm
cheers