 |
 |

01-21-2007, 04:26 AM
|
|
Newcomer
|
|
Join Date: Jan 2007
Posts: 4
|
|
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
|
|

01-21-2007, 06:59 PM
|
|
Contributor
|
|
Join Date: Oct 2004
Posts: 629
|
|
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.
|
|

01-23-2007, 03:37 AM
|
|
Newcomer
|
|
Join Date: Jan 2007
Posts: 4
|
|
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
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.
|
|
|

01-23-2007, 08:07 AM
|
|
Contributor
|
|
Join Date: Oct 2004
Posts: 629
|
|
|
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.
|
|

01-24-2007, 09:21 AM
|
|
Newcomer
|
|
Join Date: Jan 2007
Posts: 4
|
|
|
maybe where is another way ?
|
|

01-24-2007, 11:36 AM
|
|
Contributor
|
|
Join Date: Oct 2004
Posts: 629
|
|
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).
|
|

01-25-2007, 12:07 PM
|
|
Newcomer
|
|
Join Date: Jan 2007
Posts: 4
|
|
Its works,THANK YOU  !!!!
Quote:
Originally Posted by JPB
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).
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|