代码改变世界
2009-11-14 16:46
HYrz的菜园子
阅读(257)
评论()
编辑
收藏
举报
![](https://images.cnblogs.com/cnblogs_com/bsoom/dd.jpg)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
//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
..') else writeln('COULD NOT CONNECT!!');
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.