We help IT Professionals succeed at work.
Get Started

Using the Internet Transfer Control to upload a file

sbennetts
sbennetts asked
on
597 Views
Last Modified: 2012-08-14
I'm trying to use the Internet Transfer Control to upload a file using HTTP.

I know there are plenty of easier ways of achieving this via FTP, but I don't want to have to configure my server as an FTP server.  I have the following code

    Dim strURL As String
    Dim intFile As Integer
    Dim tmpPhoto() As Byte
   
    intFile = FreeFile()
    strURL = "http://10.1.200.192/sb.htm"
   
    Inet1.Execute strURL, "PUT", "c:\simon.htm"

If I execute this, my new file is copied to my web server at 10.1.200.192 but the new file contains "c:\simon.htm" rather than the actual file!

If I use the following code...

    Dim strURL As String
    Dim intFile As Integer
    Dim tmpPhoto() As Byte
   
    intFile = FreeFile()
    strURL = "http://10.1.200.192/sb.htm"
   
    Open "c:\simon.htm" For Binary Access Read As #intFile
        Get #intFile, , tmpPhoto()
    Close #intFile

    Inet1.Execute strURL, "PUT", tmpPhoto()

If I run this, it falls over telling me it 'Cannot coerce type' with a runtime error 35760.

How can I perform this simple task?

Thanks
Simon.
Comment
Watch Question
CERTIFIED EXPERT
Author of the Year 2009
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE