Link to home
Start Free TrialLog in
Avatar of sbennetts
sbennetts

asked on

Using the Internet Transfer Control to upload a file

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.
Avatar of EDDYKT
EDDYKT
Flag of Canada image

try

dim tmpPhoto as string
Avatar of sbennetts
sbennetts

ASKER

That works for a text/htm file, but I want to use it to upload JPG files
I'm managed to do it, can I not sort it myself and get my points back :-(
ASKER CERTIFIED SOLUTION
Avatar of DanRollins
DanRollins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial