兄弟,请看看下面,也可以qq:42872272
unit PTUpLoad; //×¢Òâ
TUpLoadÊǵ±Ç°unit±£´æ½¨ÒéµÄÎļþÃû
interface
uses
NMFtp, IdWinsock, windows, Dialogs, SysUtils, Classes,
ZLib, Registry, INIFILES; //×¢Òâ pdmÊÇÊý¾ÝÄ£¿épdm.pas
type TUpLoad = class
private
public
app: string;
constructor Create(lapp: string); //¹¹Ô캯Êý
function UPLOAD(ulFile: string): boolean;
end;
var UPLOAD: TUpLoad;
implementation
uses PPUBPAS;
constructor TUpLoad.Create(lapp: string); //¹¹Ô캯Êý
begin
app := lapp;
end;
function TUpLoad.UPLOAD(ulFile: string): boolean;
var NMFTP1: TNMFTP;
sDest: string;
begin
sDest := copy(ulFile, length(app) + 1, 255); // ¿ªÊ¼²»Äܺ¬ /
result := false;
NMFTP1 := TNMFTP.Create(nil);
NMFTP1.Host := getinikey(pchar(app + 'NetUpdate.ini'), 'ftp', 'Host');
NMFTP1.Port := strtoint(getinikey(pchar(app + 'NetUpdate.ini'), 'ftp', 'Port'));
NMFTP1.UserID := getinikey(pchar(app + 'NetUpdate.ini'), 'ftp', 'UserID');
NMFTP1.Password := getinikey(pchar(app + 'NetUpdate.ini'), 'ftp', 'Password');
try
NMFTP1.Connect();
except
showmessage('Ô¶³ÌFtp·þÎñÆ÷ûÓÐÆô¶¯»òûÓн¨Á¢Óû§Ãû!');
NMFTP1.Free;
exit;
end;
try
if pos('/', sDest) > 0 then NMFTP1.MakeDirectory(copy(sDest, 1, pos('/', sDest) - 1));
except
showmessage('·þÎñÆ÷Ŀ¼£º' + copy(sDest, 1, pos('/', sDest) - 1) + 'ÒѾ­´æÔÚ!');
end;
try
NMFTP1.UPLOAD(ulFile, sDest);
except
showmessage('ÉÏ´«Ê§°Ü£¬Ô­Òòδ֪£º¿ÉÄÜÊÇûÓзÖÅäÓû§Ãû£¬»òÓû§Ã»ÓÐ!');
NMFTP1.Free;
exit;
end;
NMFTP1.Free;
result := true;
end;
end.