L
lanlyli
Unregistered / Unconfirmed
GUEST, unregistred user!
我用以下代码,但是不行,不知道是怎么回事.
var
httpContext: Integer;
HttpServer, UserID, Passwd: string;
BufferIn: INTERNET_BUFFERS;
RemoteFile: string;
LocalFile: string;
httpFile: THandle;
readInF: DWORD;
oBytesWritten: DWORD;
rRead: BOOL;
iPort:integer;
Count: DWORD;
HttpNet, HttpConnect, HttpRequest: HINTERNET;
pBuffer: string;
begin
LocalFile := 'c:/prodcode.txt';
RemoteFile := '/aaa.txt';
HttpServer := 'www.qw111.com';
UserID := 'qw111.com';
Passwd := 'ys68nurw';
iPort := 128;
HttpNet := InternetOpen(PChar(HttpServer), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
httpContext := 0;
HttpConnect := InternetConnect(HttpNet, PChar(HttpServer), INTERNET_DEFAULT_HTTP_PORT, PChar(UserID),
PChar(Passwd), INTERNET_SERVICE_HTTP, 0, httpContext);
if HttpConnect=nil then
ShowMessage('ftp 连接失败.')
else
ShowMessage('ftp 连接成功.');
//设定服务端目录
FtpSetCurrentDirectory(HttpConnect,'/update');
if FileExists(LocalFile) then
begin
if FtpPutFile(HttpConnect,pchar(LocalFile),'test.txt',INTERNET_FLAG_TRANSFER_BINARY,0) then
ShowMessage('发送完毕')
else
ShowMessage('发送失败');
end
else
ShowMessage('要发送的文件不存在');
InternetCloseHandle(HttpConnect);
var
httpContext: Integer;
HttpServer, UserID, Passwd: string;
BufferIn: INTERNET_BUFFERS;
RemoteFile: string;
LocalFile: string;
httpFile: THandle;
readInF: DWORD;
oBytesWritten: DWORD;
rRead: BOOL;
iPort:integer;
Count: DWORD;
HttpNet, HttpConnect, HttpRequest: HINTERNET;
pBuffer: string;
begin
LocalFile := 'c:/prodcode.txt';
RemoteFile := '/aaa.txt';
HttpServer := 'www.qw111.com';
UserID := 'qw111.com';
Passwd := 'ys68nurw';
iPort := 128;
HttpNet := InternetOpen(PChar(HttpServer), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
httpContext := 0;
HttpConnect := InternetConnect(HttpNet, PChar(HttpServer), INTERNET_DEFAULT_HTTP_PORT, PChar(UserID),
PChar(Passwd), INTERNET_SERVICE_HTTP, 0, httpContext);
if HttpConnect=nil then
ShowMessage('ftp 连接失败.')
else
ShowMessage('ftp 连接成功.');
//设定服务端目录
FtpSetCurrentDirectory(HttpConnect,'/update');
if FileExists(LocalFile) then
begin
if FtpPutFile(HttpConnect,pchar(LocalFile),'test.txt',INTERNET_FLAG_TRANSFER_BINARY,0) then
ShowMessage('发送完毕')
else
ShowMessage('发送失败');
end
else
ShowMessage('要发送的文件不存在');
InternetCloseHandle(HttpConnect);