Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Repost: Uploading a file to a web server from a VB6 ActiveX control

111 views
Skip to first unread message

John

unread,
Jul 19, 2004, 1:19:11 PM7/19/04
to
Original post used the wrong alias. Sorry to waste the bandwidth

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.


Peter Huang

unread,
Jul 19, 2004, 9:33:13 PM7/19/04
to
Hi John,

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.

John R.

unread,
Jul 20, 2004, 6:51:03 PM7/20/04
to
Thanks but those won't work for me.

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.
---------------------------

Peter Huang

unread,
Jul 20, 2004, 11:28:00 PM7/20/04
to
Hi John,

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.

0 new messages