FTP上传示例代码
//Little sample showing how to upload file to a FTP using
//Wininet component. :D
program upoader;
{$apptype console}
uses
windows,
wininet;
var
intconn,intopen : hinternet;
procedure UploadMyFile (File2Upload:pchar; targetfilename:pchar);
const
TheFtpPort=21;
begin
writeln('Starting upload of file: '+File2upload);
writeln('Connecting to FTP
intopen := internetopen('iexplore',INTERNET_OPEN_TYPE_DIRECT,nil,nil,0);
intconn := internetconnect(intopen,'ftp.lycos.co.uk',TheFtpPort,'MyUsername','MyPassword',INTERNET_SERVICE_FTP,INTERNET_FLAG_PASSIVE,0);
sleep(100);
if getlasterror=0 then writeln('uploading now
ftpputfile(intconn,File2Upload,targetfilename,FTP_TRANSFER_TYPE_UNKNOWN,0);
internetclosehandle(intconn);
internetclosehandle(intopen) ;
if getlasterror=0 then writeln(File2upload+' was sucessfully uploaded to FTP as: '+targetfilename) else sleep(1);
END;
begin
uploadmyfile('C:\warning.wav','Uploadedfile.wav');
while True do Sleep(1000);
end.
转载于:https://www.cnblogs.com/bsoom/archive/2009/11/14/1603066.html