How to set a path (FTP) to automatically upload to Delphi?

Asked

Viewed 379 times

1

I need an Upload automatically in the code below to send to the server via FTP using Delphi, it is possible?

var
ms: TMemoryStream;


begin
if OpenDialog1.Execute then

ms := TMemoryStream.Create;



 idftp1.host := '' // Endereço do servidor FTP

 idftp1.port := ''; //Porta do servidor FTP

 idftp1.username := ''; // Parametro nome usuario servidor FTP

 idftp1.password := ''; // Parametro senha servidor FTP

 idftp1.Connect();



(Aqui Preciso mudar)

 idftp1.Put(OpenDialog1.FileName, '/projeto_ftp/' + ExtractFileName(OpenDialog1.FileName));

IdFTP1.Disconnect;



end;

1 answer

0

idftp1.host := '' // FTP server address

idftp1.port := ''; //FTP server port

idftp1.username := ''; // Parameter name FTP server user

idftp1.password := ''; // FTP server password parameter

idftp1.Connect();

(Here I need to change)

Put idftp1.Put(Opendialog1.Filename, '/project_ftp/' + Extractfilename(Opendialog1.Filename));

Disconnect;

Try it like this...

 idftp1.host := '' // Endereço do servidor FTP
 idftp1.port := ''; //Porta do servidor FTP
 idftp1.username := ''; // Parametro nome usuario servidor FTP
 idftp1.password := ''; // Parametro senha servidor FTP
  try
    idftp1.Connect(true, -1);
  except
    idftp1.Passive := True;
    idftp1.Connect;
  end;
idftp1.ChangeDir('/var/www/html'); //SEU DIRETORIO

//CAMINHO COMPLETO DO LOCAL QUE O ARQUIVO ESTA EM SUA MAQUINA
idftp1.Put('C:\Arquivo.txt', 'Arquivo.txt', false);
IdFTP1.Disconnect;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.