How do you upload a file to a web server from a VB6 ActiveX control using
HTTP?
I have written an ActiveX control in VB 6.0.
The problem is that I need to upload a local file from the workstation to a
web site using HTTP.
I have tried a bunch of different things but nothing seems to work.
Here's what I've tried:
Attempt 1:
In this attempt I wonder, where do I specify the URL to send the file to?
Dim myResponse As Response
Dim f As File
Dim ts As TextStream
Dim s As String
Set f = fso.GetFile(tempFilePath)
Set ts = f.OpenAsTextStream(ForReading)
s = ts.ReadAll
myResponse.AddHeader "Content-Disposition", "filename=" + tempFile
myResponse.AddHeader "Content-Length", Str(Len(s))
myResponse.AddHeader "Accept-Ranges", "s"
myResponse.ContentType = "Application/Other"
myResponse.BinaryWrite s
Attempt 2:
I'm not sure if this uploads a file.
Dim xmlHttp As New XMLHTTP30
xmlHttp.open "POST", "http://localhost/Reports/myFile.car", False
xmlHttp.send localFile
Thanks for your help in advance.
Here are a few links about how to upload file to a webserver.
HOW TO: Upload Files to a Web Server by Using ASP (299692)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;299692
Upload files with XMLHTTP
http://builder.com.com/5100-31-5078105.html
Solution Title: how can i upload the file by xml and asp?
http://www.experts-exchange.com/Web/Web_Languages/ASP/Q_20884703.html
Posting with Inet Control
http://groups.google.com/groups?hl=zh-CN&lr=&ie=UTF-8&selm=vuzjbb3nDHA.1804%
40cpmsftngxa06.phx.gbl
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
The "Upload files with XMLHTTP" and "Solution Title: how can i upload the file by xml and asp?" suggestions both use ADODB.Stream so I can't use them because of the critical update "KB870669 - Critical Update for Microsoft Data Access Components - Disable ADODB.Stream object from Internet Explorer".
The other two examples are for posting and I could possibly do that but it does seem quite a bit overkill.
I'm just trying to upload a file on a workstation to a web server from an ActiveX control. Is there an easier way?
Thanks,
John R.
---------------------------
Another way is to use the ftp directly, which is somewhat easy.
If you do want to use the PUT command with HTTP, I will follow up in your
another thread in the group.