Y
yyy_as
Unregistered / Unconfirmed
GUEST, unregistred user!
IdFTP 上传文本文件(还不到1k)特别慢,是何原因?我用的是Passive模式。是不是和
传输模式有关?又不象?我怀疑是我上传的方式有关?但又不知道如何做,能帮忙一下吗?
最好有简单的代码。
procedure TfrmUpload.Timer1Timer(Sender: TObject);
var
AppPath,FileName,LocalFile,RemoteFile:string;
sr:TSearchRec;
FileAttrs:Integer;
begin
timer1.Enabled :=false;
AppPath:=ExtractFilePath(Application.exeName);
LocalFile:= AppPath+'bbb/';
RemoteFile:='/aaaa/bbb/';
{查找某一目录文件,此目录应只有一个文件}
FileAttrs := faArchive;
if FindFirst(LocalFile +'*.txt',FileAttrs,sr)=0 then
if (sr.Name<>'.') and (sr.Name<>'..') and (sr.Size>0) then begin
FileName:=sr.Name;
if FindNext(sr)=0 then begin
Label1.Caption :='exit';
exit;
end;
FindClose(sr);
end;
if Length(FileName)=0 then begin
Label1.Caption :='没有需要上传的文件';
exit;
end;
{连接服务器}
label1.Caption :='连接...';
IdFTP1.Host:='111.222.33.444';
IdFTP1.Port:=21;
IdFTP1.User:='aaa';
IdFTP1.Password:='bbb';
try
IdFTP1.Connect;
except
On E:Exception do writeln(E.message);
end;
try {上传文本文件}
IdFtp1.TransferType := ftASCII;
IdFtp1.Passive:=true;
IdFTP1.Put(LocalFile+FileName,RemoteFile+FileName,false);
deletefile(LocalFile+FileName);
Label1.Caption :=' 上传成功';
except
on E:Exception do
begin
showmessage(E.Message);
IdFtp1.Disconnect;
end;
end;
IdFTP1.Disconnect;
end;
传输模式有关?又不象?我怀疑是我上传的方式有关?但又不知道如何做,能帮忙一下吗?
最好有简单的代码。
procedure TfrmUpload.Timer1Timer(Sender: TObject);
var
AppPath,FileName,LocalFile,RemoteFile:string;
sr:TSearchRec;
FileAttrs:Integer;
begin
timer1.Enabled :=false;
AppPath:=ExtractFilePath(Application.exeName);
LocalFile:= AppPath+'bbb/';
RemoteFile:='/aaaa/bbb/';
{查找某一目录文件,此目录应只有一个文件}
FileAttrs := faArchive;
if FindFirst(LocalFile +'*.txt',FileAttrs,sr)=0 then
if (sr.Name<>'.') and (sr.Name<>'..') and (sr.Size>0) then begin
FileName:=sr.Name;
if FindNext(sr)=0 then begin
Label1.Caption :='exit';
exit;
end;
FindClose(sr);
end;
if Length(FileName)=0 then begin
Label1.Caption :='没有需要上传的文件';
exit;
end;
{连接服务器}
label1.Caption :='连接...';
IdFTP1.Host:='111.222.33.444';
IdFTP1.Port:=21;
IdFTP1.User:='aaa';
IdFTP1.Password:='bbb';
try
IdFTP1.Connect;
except
On E:Exception do writeln(E.message);
end;
try {上传文本文件}
IdFtp1.TransferType := ftASCII;
IdFtp1.Passive:=true;
IdFTP1.Put(LocalFile+FileName,RemoteFile+FileName,false);
deletefile(LocalFile+FileName);
Label1.Caption :=' 上传成功';
except
on E:Exception do
begin
showmessage(E.Message);
IdFtp1.Disconnect;
end;
end;
IdFTP1.Disconnect;
end;