Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Communications > uploadin FTP dilema PLEASE help


Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2007, 04:26 AM
bultiko bultiko is offline
Newcomer
 
Join Date: Jan 2007
Posts: 4
Default uploadin FTP dilema PLEASE help


Please HELP....im new to VB...i use vb6 and i need a sample how
to upload file frew Internet explorer to FTP (NOT winnet,winsok,shell....)


Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")

ClipboardCopyFiles "C:\text.txt" ' need to copy text file and sent it to ftp
IE.Navigate2 "ftp://loginassw@ftp.my.com"
ClipboardPasteFiles("/text.txt") 'i need simles way to upload file frew Internet explorer to FTP (NOT winnet,winsok,shell....)
i didnt think its simple question...i was googling.Reading forums..and still no answer..!!!
My mission is:
to upload file.txt via http (using Internet Explorer or WebBrowser components. NOT frew winet,winsock,shell and others ways...I need this very much)

we can send direct commands somehow to ftp "PUT,GET,DIR" or data stream..or....(i mean by WebBrowser1.execWB...or.IE somehow...????)
Main idea is to upload file to ftp using ONLY InternetExplorer or WebBrowser1
Reply With Quote
  #2  
Old 01-21-2007, 06:59 PM
JPB JPB is offline
Contributor
 
Join Date: Oct 2004
Posts: 629
Default

If you use the WebBrowser control, you should be able to navigate to an FTP server as follows:

Code:
Private Sub Form_Load()
    Me.WebBrowser1.Navigate "ftp://www.site.com"
End Sub
Then, you should wait until you are connected to the FTP server before doing anything. You can define a module level variable (i.e. Private mblnBrowserReady As Boolean), then set it to TRUE when connected:

Code:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If (pDisp Is Me.WebBrowser1.Object) Then
        mblnBrowserReady = True
    End If
End Sub
Finally, you can add a CommandButton and let the user upload files via the clipboard as follows:

Code:
Private Sub Command1_Click()
    If mblnBrowserReady Then ' The WebBrowser has connected to the FTP server
        ClipboardCopyFiles "C:\text.txt" ' Copy the files to the clipboard

         Me.WebBrowser1.SetFocus ' The WebBrowser control must be visible for this to work         
         SendKeys "^v" ' Send a Ctrl+V (Paste) operation to the WebBrowser
    Else
        MsgBox "Please wait for the web browser to connect to FTP." ' We haven't connected yet, so provide an error message
    End If
End Sub
I assume that the ClipboardCopyFiles procedure you mention works properly in order for the above code to work.
Reply With Quote
  #3  
Old 01-23-2007, 03:37 AM
bultiko bultiko is offline
Newcomer
 
Join Date: Jan 2007
Posts: 4
Default

How to make it auto copy?

if i write
Private Sub Form_Load()
ClipboardCopyFiles "C:\text.txt" ' Copy the files to the clipboard

Me.WebBrowser1.SetFocus ' The WebBrowser control must be visible
SendKeys "^v" ' Send a Ctrl+V (Paste) operation to the WebBrowser
End Sub


show error on WebBrowser1.seFocus
Run time error '5'
invalid procedure or call argument

I tryed to use:
sleep,loop webbrowser1.result and so on......
tryed to call AssureWebBrowser.....
NOTHING helped.............
Private Sub AssureWebBrowser()

While WebBrowser1.Busy
WaitMS 575
Wend
While Not ActiveControl Is WebBrowser1
WebBrowser1.SetFocus
WaitMS (550)
Wend
End Sub








Quote:
Originally Posted by JPB View Post
If you use the WebBrowser control, you should be able to navigate to an FTP server as follows:

Code:
Private Sub Form_Load()
    Me.WebBrowser1.Navigate "ftp://www.site.com"
End Sub
Then, you should wait until you are connected to the FTP server before doing anything. You can define a module level variable (i.e. Private mblnBrowserReady As Boolean), then set it to TRUE when connected:

Code:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If (pDisp Is Me.WebBrowser1.Object) Then
        mblnBrowserReady = True
    End If
End Sub
Finally, you can add a CommandButton and let the user upload files via the clipboard as follows:

Code:
Private Sub Command1_Click()
    If mblnBrowserReady Then ' The WebBrowser has connected to the FTP server
        ClipboardCopyFiles "C:\text.txt" ' Copy the files to the clipboard

         Me.WebBrowser1.SetFocus ' The WebBrowser control must be visible for this to work         
         SendKeys "^v" ' Send a Ctrl+V (Paste) operation to the WebBrowser
    Else
        MsgBox "Please wait for the web browser to connect to FTP." ' We haven't connected yet, so provide an error message
    End If
End Sub
I assume that the ClipboardCopyFiles procedure you mention works properly in order for the above code to work.
Reply With Quote
  #4  
Old 01-23-2007, 08:07 AM
JPB JPB is offline
Contributor
 
Join Date: Oct 2004
Posts: 629
Default

As mentioned in the .SetFocus line comments, the WebBrowser control MUST be visible on-screen or you will get this error. That means the Visible property of the WebBrowser control must be True, and you can't call the SetFocus method in the Form_Load event.
Reply With Quote
  #5  
Old 01-24-2007, 09:21 AM
bultiko bultiko is offline
Newcomer
 
Join Date: Jan 2007
Posts: 4
Default

maybe where is another way ?
Reply With Quote
  #6  
Old 01-24-2007, 11:36 AM
JPB JPB is offline
Contributor
 
Join Date: Oct 2004
Posts: 629
Default

You could move the WebBrowser control off the visible area of the form, i.e.

Code:
Private Sub Form_Resize()
    Me.WebBrowser1.Move -Screen.TwipsPerPixelX, -Screen.TwipsPerPixelY, 0, 0
End Sub
But you will still have to have a visible form for this to work (i.e. Put the code to Paste the files to the WebBrowser control in a CommandButton Click event, or other event that occurs when a form is visible on screen. NOT the Form_Load event).
Reply With Quote
  #7  
Old 01-25-2007, 12:07 PM
bultiko bultiko is offline
Newcomer
 
Join Date: Jan 2007
Posts: 4
Default

Its works,THANK YOU !!!!


Quote:
Originally Posted by JPB View Post
You could move the WebBrowser control off the visible area of the form, i.e.

Code:
Private Sub Form_Resize()
    Me.WebBrowser1.Move -Screen.TwipsPerPixelX, -Screen.TwipsPerPixelY, 0, 0
End Sub
But you will still have to have a visible form for this to work (i.e. Put the code to Paste the files to the WebBrowser control in a CommandButton Click event, or other event that occurs when a form is visible on screen. NOT the Form_Load event).
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->