Hi All,
I need to upload a file to a remote server, and being a total newbie at
internet-enabling applications, took what I hope is the simplest
workable approach. The code below works OK, in that it finds the local
file and puts it where I want it to be on the remote server.
However, how secure is this? Are the username and password decypherable
if some scoundrel intercepts the transfer? Are there any simple
techniques or tools that would allow me to monitor what gets sent?
Would it be any better to use HTTP?
Any suggestions for tutorial material to bring me up to speed would be
much appreciated.
Thanks
Rob
8< ---------------------------------------------------
( This is a bit stripped down, with no error messages to signal that
the "if's" turned out to be false, etc. )
function TForm1.UploadFile: boolean;
// Put WinInet in the uses clause
//
// Needs 6 LabelledEdit controls on the form:
// leIPAddress.Text - holds the Domain name or IP address of remote host
// leUsername.Text - holds the username
// lePassword.Text - holds the password
// leRemotePath.Text - holds the path to the folder on the reote host
// lePutFile.Text - holds the qualified name of the file to send on
the local machine
// leRemoteFile.Text - holds the (unqualified) name of the file on the
remote host after upload
//
// Method "UpdateLog(s: string)" adds a timestamped line of text in a
log file
var
hSession, hFTP: HInternet;
begin
UpdateLog('Started to upload the file');
// Initiate internet session
hSession := InternetOpen(pChar(ExtractFileName(Application.ExeName)),
INTERNET_OPEN_TYPE_PRECONFIG,
nil, nil, 0);
try
// Make an FTP connection
hFTP := InternetConnect(hSession,
PChar(leIPAddress.Text),
INTERNET_DEFAULT_FTP_PORT,
PChar(leUsername.Text),
PChar(lePassword.Text),
INTERNET_SERVICE_FTP,
0, 0);
try
// set the working directory
if FtpSetCurrentDirectory(hFTP, PChar(leRemotePath.Text)) then
begin
// send the file
if
FtpPutFile(hFTP,PChar(lePutFile.Text),PChar(leRemoteFile.Text),0,0) then
begin
UpdateLog('File uploaded OK');
Result := true;
end;
end;
finally
InternetCloseHandle(hFTP);
end;
finally
InternetCloseHandle(hSession);
UpdateLog('FTP ended');
end;
end;
8< ---------------------------------------------------
Dr Rob Cameron
Lattice Networks Limited
web: www.lattice-net.co.uk
-------------------------------
Reclaim Your Inbox!
http://www.mozilla.org/products/thunderbird/
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi