Discussion:
FTP a File
(too old to reply)
Barry Wood
2006-05-03 18:00:04 UTC
Permalink
Hi

Being pretty new to ftp'ing I get confused with all the stuff that's
available. I need to start with a simple example and then I can work from
there.

Does anybody have some code that would enable me to ftp a small file up to
an ftp server? I have all the ftp info etc and can easily do this via the
cmd window. It would be nice to do it from code.

Barry
Remy Lebeau (TeamB)
2006-05-03 18:40:36 UTC
Permalink
Post by Barry Wood
Being pretty new to ftp'ing I get confused with all the stuff that's
available. I need to start with a simple example and then I can work from
there.
If you use Indy, then use the TIdFTP component, ie:

IdFTP1.Host = 'whatever';
IdFTP1.Port := 21;
IdFTP1.Connect;
try
IdFTP1.ChangeDir('/whatever');
IdFTP1.Put('c:\localfolder\file.ext', 'file.ext');
finally
IdFTP1.Disconnect;
end;


Gambit
Barry Wood
2006-05-04 07:42:17 UTC
Permalink
Remy

Many thanks for that. I tried this code (I added the password parameter as
well), but I keep getting ' Identity not known'. I'm sure the host name &
password are correct, could it be something else not set correctly do you
think?

PS I 've set binary & passive mode (as that is what my other ftp program has
setup)..

Barry
Post by Remy Lebeau (TeamB)
Post by Barry Wood
Being pretty new to ftp'ing I get confused with all the stuff that's
available. I need to start with a simple example and then I can work from
there.
IdFTP1.Host = 'whatever';
IdFTP1.Port := 21;
IdFTP1.Connect;
try
IdFTP1.ChangeDir('/whatever');
IdFTP1.Put('c:\localfolder\file.ext', 'file.ext');
finally
IdFTP1.Disconnect;
end;
Gambit
Guillem
2006-05-04 09:30:31 UTC
Permalink
Post by Barry Wood
Remy
Many thanks for that. I tried this code (I added the password
parameter as well), but I keep getting ' Identity not known'. I'm
sure the host name & password are correct, could it be something else
not set correctly do you think?
PS I 've set binary & passive mode (as that is what my other ftp
program has setup)..
Barry
you speak about host name and password. What about username?
--
Best regards :)

Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam
Barry Wood
2006-05-04 17:28:31 UTC
Permalink
Guillem,

Silly me! Yes I've put in the Username & it connects & transfers a file OK
now.

Many thanks.

Barry
Post by Guillem
Post by Barry Wood
Remy
Many thanks for that. I tried this code (I added the password
parameter as well), but I keep getting ' Identity not known'. I'm
sure the host name & password are correct, could it be something else
not set correctly do you think?
PS I 've set binary & passive mode (as that is what my other ftp
program has setup)..
Barry
you speak about host name and password. What about username?
--
Best regards :)
Guillem Vicens Meier
Dep. Informatica Green Service S.A.
www.clubgreenoasis.com
--
Contribute to the Indy Docs project: http://docs.indyproject.org
--
In order to contact me remove the -nospam
a***@medisinuio.no
2006-05-07 12:41:26 UTC
Permalink
Post by Remy Lebeau (TeamB)
Post by Barry Wood
Being pretty new to ftp'ing I get confused with all the stuff that's
available. I need to start with a simple example and then I can work from
there.
IdFTP1.Host = 'whatever';
IdFTP1.Port := 21;
IdFTP1.Connect;
try
IdFTP1.ChangeDir('/whatever');
IdFTP1.Put('c:\localfolder\file.ext', 'file.ext');
finally
IdFTP1.Disconnect;
end;
Since more and more FTP-servers now block for normal FTP and require SFTP
connections, I would like to see a simple basic setup for SFTP. Is that
possible?
Remy Lebeau (TeamB)
2006-05-08 20:02:34 UTC
Permalink
Post by a***@medisinuio.no
Since more and more FTP-servers now block for normal FTP and
require SFTP connections, I would like to see a simple basic setup
for SFTP. Is that possible?
Indy has support for SSL. Simply attach a TIdSSLIOHandlerSocket (Indy 9) or
TIdSSLIOHandlerSocketOpenSSL (Indy 10) component to the TIdFTP, configure
the SSL options as needed, and then use TIdFTP as you normally would. The
SSL will be handled transparently. Of course, you have to make sure that
you have the proper version of OpenSSL installed on the client machine as
well.


Gambit
Francois Piette [ICS & Midware]
2006-05-04 09:32:29 UTC
Permalink
Post by Barry Wood
Being pretty new to ftp'ing I get confused with all the stuff that's
available. I need to start with a simple example and then I can work from
there.
Does anybody have some code that would enable me to ftp a small file up to
an ftp server? I have all the ftp info etc and can easily do this via the
cmd window. It would be nice to do it from code.
Using ICS (http://www.overbyte.be), create a new project, drop a button and
a memo on the main form.
Assign the events as below, then run.

procedure TForm1.Button1Click(Sender: TObject);
begin
FtpClient1.HostName := 'ftp.borland.com';
FtpClient1.HostDirName := 'pub/delphi/devsupport/general';
FtpClient1.HostFileName := 'index.txt';
FtpClient1.UserName := 'anonymous';
FtpClient1.PassWord := '***@company.com';
FtpClient1.LocalFileName := 'c:\temp\index.txt';
FtpClient1.ReceiveAsync; // Or Receive if you want to be blocking
end;

procedure TForm1.FtpClient1Display(Sender: TObject; var Msg: String);
begin
Memo1.Lines.Add(Msg);
end;

procedure TForm1.FtpClient1RequestDone(Sender: TObject;
RqType: TFtpRequest; ErrCode: Word);
begin
Memo1.Lines.Add('Done ' + IntToStr(ErrCode));
end;


--
Contribute to the SSL Effort.
Visit http://www.overbyte.be/eng/ssl.html
--
***@overbyte.be
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be
Barry Wood
2006-05-04 18:16:53 UTC
Permalink
Francois

I'll give this a go - anything to make life simpler ...

Barry
Post by Francois Piette [ICS & Midware]
Post by Barry Wood
Being pretty new to ftp'ing I get confused with all the stuff that's
available. I need to start with a simple example and then I can work from
there.
Does anybody have some code that would enable me to ftp a small file up to
an ftp server? I have all the ftp info etc and can easily do this via the
cmd window. It would be nice to do it from code.
Using ICS (http://www.overbyte.be), create a new project, drop a button and
a memo on the main form.
Assign the events as below, then run.
procedure TForm1.Button1Click(Sender: TObject);
begin
FtpClient1.HostName := 'ftp.borland.com';
FtpClient1.HostDirName := 'pub/delphi/devsupport/general';
FtpClient1.HostFileName := 'index.txt';
FtpClient1.UserName := 'anonymous';
FtpClient1.LocalFileName := 'c:\temp\index.txt';
FtpClient1.ReceiveAsync; // Or Receive if you want to be blocking
end;
procedure TForm1.FtpClient1Display(Sender: TObject; var Msg: String);
begin
Memo1.Lines.Add(Msg);
end;
procedure TForm1.FtpClient1RequestDone(Sender: TObject;
RqType: TFtpRequest; ErrCode: Word);
begin
Memo1.Lines.Add('Done ' + IntToStr(ErrCode));
end;
--
Contribute to the SSL Effort.
Visit http://www.overbyte.be/eng/ssl.html
--
Author of ICS (Internet Component Suite, freeware)
Author of MidWare (Multi-tier framework, freeware)
http://www.overbyte.be
m***@gmail.com
2012-10-16 08:40:19 UTC
Permalink
Post by Barry Wood
Hi
Being pretty new to ftp'ing I get confused with all the stuff that's
available. I need to start with a simple example and then I can work from
there.
Does anybody have some code that would enable me to ftp a small file up to
an ftp server? I have all the ftp info etc and can easily do this via the
cmd window. It would be nice to do it from code.
Barry
Hi
Please Can you please give us an example of code using Indy for an sftp transfer ??

Thanks a lot

Loading...