我对这个程序进行了编码,以使用 ftpput api 在服务器上上传文件,它无法运行,但文件未删除!
这是代码:
unit ftp3;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,wininet;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var hInet, hConnect: HINTERNET;
local_file,
remote_file,
user,remote_server,
pass: pchar;
begin
local_file := 'C:\Documents and Settings\Omair\Desktop\loggen.txt';
remote_file := 'loggen.txt';
user := 'my user';
pass := 'my pass';
remote_server := ' ftp.drivehq.com';
hInet := InternetOpen(0, INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0);
hConnect := InternetConnect(hInet,
remote_server,
INTERNET_DEFAULT_FTP_PORT,
user, pass,
INTERNET_SERVICE_FTP,
INTERNET_FLAG_PASSIVE,
0);
ftpPutFile(hConnect, local_file, remote_file, FTP_TRANSFER_TYPE_BINARY, 0);
InternetCloseHandle(hInet);
InternetCloseHandle(hConnect);
end;
end.