procedure TForm1.Button1Click(Sender: TObject);
var
LocalFile,
RemoteFile: String;
F: File of Byte;
FSize: Integer;
O: TOpenDialog;
begin
NMFTP1.Connect ;
O := TOpenDialog.Create(Self);
try
O.Title := 'Select file to upload';
if O.Execute then
if InputQuery('Choose Remote File Name', 'Filename?', RemoteFile) then
begin
LocalFile := O.FileName;
AssignFile(F, LocalFile);
Reset(F);
FSize := FileSize(F);
CloseFile(F);
NMFTP1.Allocate(FSize);
pgb.Max := FSIZE;//pgb是win32页上的TProgressBar
pgb.Position := 0;
NMFTP1.Upload(LocalFile, RemoteFile);
end;
finally
O.Free;
end;
end;
procedure TForm1.NMFTP1Success(Trans_Type: TCmdType);
begin
pgb.Position := 0;
end;
procedure TForm1.NMFTP1PacketSent(Sender: TObject);
begin
pgb.Position := NMFTP1.BytesSent;
end;