- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi 使用Indy idftp 通过Android 上传文件
var
ftp_port,ftp_folder:string;
ftp_error : Boolean;
begin
IdFTP1.ConnectTimeout := 1000;
IdFTP1.Passive := True;
IdFTP1.Host := '';//ftp_server;
IdFTP1.Username:= '';//ftp_user;
IdFTP1.Password:= '';//ftp_pass;
if ftp_port<> '' then begin
Try
IdFTP1.Port := StrToInt(ftp_port);
except
IdFTP1.Port := 21;
End;
end;
Try
ftp_error := False;
IdFTP1.Connect;
IdFTP1.Passive := true;
if ftp_folder= '' then
IdFTP1.Put( System.IOUtils.TPath.Combine(System.IOUtils.tpath.getdocumentspath,'temp.txt'), ftp_file, False )
else begin
if ftp_folder[length(ftp_folder)] <> '/' then
ftp_folder:= ftp_folder+ '/';
IdFTP1.Put( System.IOUtils.TPath.Combine(System.IOUtils.tpath.getdocumentspath,'temp.txt'), ftp_folder+ftp_file, False );
end;
IdFTP1.Disconnect;
except
ftp_error := True;
End;
if not ftp_error then begin
showmessage('FTP connection correct');
end
else begin
showmessage('Error FTP');
end;