Click to See Complete Forum and Search --> : Upload files to FTP Server


Dr_Michael
August 17th, 1999, 03:45 AM
How can I upload files to an FTP Server (with VB). Please help me in depth because I am begginer with Internet :-(

Mi

Dr_Michael
August 17th, 1999, 04:26 AM
I found a good OCX on this site:
http://ftp.devpower.com/
Let's try it...%

Chris Eastwood
August 17th, 1999, 05:32 AM
You could download my free class modules that I posted onto the CodeGuru site at http://www.codeguru.com/vb/articles/1852.shtml

These will let you FTP files from VB.



Chris Eastwood

CodeGuru - the website for developers
http://www.codeguru.com/vb

Dr_Michael
August 17th, 1999, 05:45 AM
The ocx I found was a better one because it lets you create directories. Thanx anyway...

Michael Vlastos
Company MODUS SA
Development Department
Athens, Greece
Tel: +3-01-9414900

Chris Eastwood
August 17th, 1999, 05:51 AM
The WinInet.DLL allows you to create a directory on the server, you'd need to place a new declare in the code -

The C Declaration is :

BOOLAPI
FtpCreateDirectoryA(
IN HINTERNET hConnect,
IN LPCSTR lpszDirectory
);




or for unicode


BOOLAPI
FtpCreateDirectoryW
IN HINTERNET hConnect,
IN LPCWSTR lpszDirectory
);




It should be pretty easy to translate these into the relevant vb declarations and then add the methods into the class - and all for FREE !




Chris Eastwood

CodeGuru - the website for developers
http://www.codeguru.com/vb

Dr_Michael
August 17th, 1999, 05:53 AM
I'll try both and select the better one. Thanx Chris one more time...

Michael Vlastos
Company MODUS SA
Development Department
Athens, Greece
Tel: +3-01-9414900

Chris Eastwood
August 17th, 1999, 06:01 AM
In fact, I've already converted that declare and tested it here - works fine.

Place the following 'declare' in the cFTP class :


private Declare Function FtpCreateDirectory Lib "wininet.dll" Alias "FtpCreateDirectoryA" _
(byval hFtpSession as Long, byval lpszDirectory as string) as Boolean




Then place a routine similar to this one in the cFTP class :


public Function CreateDirectory(byval sDirectory as string) as Boolean

on error GoTo vbErrorHandler

Dim bRet as Boolean

If mlConnection = 0 then
on error GoTo 0
Err.Raise errNotConnectedToSite, "CGFTP::GetFile", ERRNOCONNECTION
End If

bRet = FtpCreateDirectory(mlConnection, sDirectory)

If bRet = false then
'
' couldn't create directory - add extra errors to the class
' to handle this
'
End If

CreateDirectory = bRet

Exit Function

vbErrorHandler:
Err.Raise Err.Number, "cFTP::CreateDirectory", Err.Description

End Function







Chris Eastwood

CodeGuru - the website for developers
http://www.codeguru.com/vb