Internet Transfer Control - Upload File With http 
Author Message
 Internet Transfer Control - Upload File With http

I am trying to upload a file from local PC to a web server
using HTTP, not allowed to use FTP.  I have this in my VB
code but it doesn't work. No errors though.  Do I need a
password or to set up the web server somehow?
Linda
Private Sub Command1_Click()

  LocalTarget = "C:\lptest.txt"
  RemoteTarget = "lptest.txt"  

  Inet1.URL
= " http://www.*-*-*.com/ ;  

  Inet1.Execute Inet1.URL, "PUT " & LocalTarget & " " &
RemoteTarget

End Sub



Mon, 02 May 2005 00:20:06 GMT  
 Internet Transfer Control - Upload File With http
Hi,

you might want to try the following to get closer to the solution:

1. Add a label to your form named lblState
2. Add this line to the Internet control's StateChanged event:
    Private Sub Inet1_StateChanged(ByVal State As Integer)
        lblState.Caption= "State= " & State
    End Sub
You can then see what's happening during the connection process. Here's a
list of the possible states taken from the MSDN library:
The settings for State are:

      Constant Value Description
      icNone 0 No state to report.
      icHostResolvingHost 1 The control is looking up the IP address of the
specified host computer.
      icHostResolved 2 The control successfully found the IP address of the
specified host computer.
      icConnecting 3 The control is connecting to the host computer.
      icConnected 4 The control successfully connected to the host computer.
      icRequesting 5 The control is sending a request to the host computer.
      icRequestSent 6 The control successfully sent the request.
      icReceivingResponse 7 The control is receiving a response from the
host computer.
      icResponseReceived 8 The control successfully received a response from
the host computer.
      icDisconnecting 9 The control is disconnecting from the host computer.
      icDisconnected 10 The control successfully disconnected from the host
computer.
      icError 11 An error occurred in communicating with the host computer.
      icResponseCompleted 12 The request has completed and all data has been
received.

Other checks to perform:
See if you can ping your counterpart, if the hostname resolves etc...
And finally some more from MSDN about HTTP transfer:

Using the Execute Method with the HTTP Protocol
The HTTP protocol allows client machines to request data from the server
using the GET, HEAD, POST, and PUT commands. These operations are shown in
the following table:

      Operation Description Example
      GET Retrieves the file named in url. Execute
"http://www.microsoft.com" & _
"/default.htm", "GET"

      HEAD Retrieves only the headers of the file named in the URL property.
Execute , "HEAD"

      POST Provides additional data to support a request to the remote host.
Execute , "POST", strFormData

      PUT Replaces data at the specified URL. Execute , "PUT", "replace.htm"

Hope that helps a little,

Regards,
Wolfgang



Quote:
> I am trying to upload a file from local PC to a web server
> using HTTP, not allowed to use FTP.  I have this in my VB
> code but it doesn't work. No errors though.  Do I need a
> password or to set up the web server somehow?
> Linda
> Private Sub Command1_Click()

>   LocalTarget = "C:\lptest.txt"
>   RemoteTarget = "lptest.txt"

>   Inet1.URL
> = "http://www.mywebsite.co.uk/folder/Pictures/"

>   Inet1.Execute Inet1.URL, "PUT " & LocalTarget & " " &
> RemoteTarget

> End Sub



Sat, 07 May 2005 18:21:33 GMT  
 Internet Transfer Control - Upload File With http
Linda,

here's how to do it (basically). See if you can get it to work:

Private Sub Command1_Click()
    LocalDir = txtLocalDir.Text ' You have to add this to your form before,
of course
    ChDir LocalDir ' RemoteTarget is not needed anymore
    LocalTarget ="lptest.txt"
    Inet1.URL = "http://www.mywebsite.co.uk/folder/Pictures/"
    Inet1.Document=LocalTarget 'If this is not set for a PUT operation with
HTTP, it will generate an error
    Inet1.Execute , "PUT"
End Sub

Your code is not working for HTTP transfer, what you tried was the command
syntax for FTP.
I tried the way you did it (with modifications for HTTP) on my UNIX-based
Apache server and the error logs showed "... Illegal filename
/usr/apache/htdocs/c:/lptest.txt"

With above code depending on the server configuration you may get an http
error 405 (requested method not allowed) or 403 (access to the page
forbidden).
That's server security configuration and doesn't have to do anything with
bugs in your code. You can have the admin reconfigure teh server but I can
only guess if he will do that, probably not...

Anyway, in your return value you must look for http message 200 (request
OK).

Hope that helps!

Wolfgang



Quote:
> I am trying to upload a file from local PC to a web server
> using HTTP, not allowed to use FTP.  I have this in my VB
> code but it doesn't work. No errors though.  Do I need a
> password or to set up the web server somehow?
> Linda
> Private Sub Command1_Click()

>   LocalTarget = "C:\lptest.txt"
>   RemoteTarget = "lptest.txt"

>   Inet1.URL
> = "http://www.mywebsite.co.uk/folder/Pictures/"

>   Inet1.Execute Inet1.URL, "PUT " & LocalTarget & " " &
> RemoteTarget

> End Sub



Sun, 08 May 2005 18:16:34 GMT  
 Internet Transfer Control - Upload File With http
I am having a similar problem. Linda, did you ever figure out how to do it.
I put the same code in as you did, added the Inet control and when I click
on the associated command button, nothing happens. (I am connected to the
internet through a cable modem so internet access is not the issue).

Thanks
Lorne


Quote:
> I am trying to upload a file from local PC to a web server
> using HTTP, not allowed to use FTP.  I have this in my VB
> code but it doesn't work. No errors though.  Do I need a
> password or to set up the web server somehow?
> Linda
> Private Sub Command1_Click()

>   LocalTarget = "C:\lptest.txt"
>   RemoteTarget = "lptest.txt"

>   Inet1.URL
> = "http://www.mywebsite.co.uk/folder/Pictures/"

>   Inet1.Execute Inet1.URL, "PUT " & LocalTarget & " " &
> RemoteTarget

> End Sub



Thu, 19 May 2005 13:37:53 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. File upload using Internet Transfer Control and HTTP PUT

2. How to upload a file by Internet Transfer Control in HTTP protocol

3. Uploading File with HTTP POST useing the VB5.0(sp3) internet transfer Control

4. File upload using Internet Transfer Control and HTTP PUT

5. HTTP file upload using Internet transfer control

6. Internet Transfer Control and HTTP Uploads

7. Datei Upload per HTTP / File upload via HTTP

8. problem uploading file with internet transfer control

9. problem uploading a file using internet transfer control

10. Help on Upload a file using Internet Transfer control

11. Uploading Multiple Files: Internet Transfer Protocol

12. Using Internet Transfer Control to Upload

 

 
Powered by phpBB® Forum Software