1.服务器上安装的filezilla程序,采取被动模式,做了动态域名映射,端口也都放开了
2.用delphi做的程序通过idftp连接ftp服务器,用来上传和下载文件
3.公司内部使用没有问题
4.外网用户通过浏览器,文件夹都可以正常访问公司的ftp服务器获取文件
但是有部分用户使用delphi开发的程序时,却连不上,奇怪的是他们把电脑
连上手机热点的网络后却可以正常使用。还有的之前用家里的网使用的一切正常,后来t突就然就连不上了
begin
with TIdFTP.Create(nil) do
try
Port := gftp_port;
Passive :=true;
PassiveUseControlHost := true;
Host := gFtpserver;
Username := gftp_user;
Password := gftp_pass;
lst := TStringList.Create;
try
Connect; //在这里报错
cxm1.Lines.Clear;
cxm1.Lines.Add('开始下载文件...');
tblo.First;
while not tblo.EOF do
begin
bc := tblo.FieldByName('bcode').Value;
sp := Format('\Original\%s\%s\', [formatdatetime('yyyymmdd',tblo.FieldByName('bdate').AsDateTime), bc]);
fd := cxbtndt1.Text;
if tblo.FieldByName('file1').IsNull then
sf := ''
else
sf := tblo.FieldByName('file1').Value;
if sf <> '' then
begin
try
//修改了文件名称,文件名称为订单ID+文件名称
sf1 := tblo.FieldByName('wo_id').AsString + '_'+sf;
if FileExists(fd+sf1) then DeleteFile(fd+sf1);
Get(sp+sf, fd+sf1);
//cxm1.Lines.Add(Format('%s 文件%s下载完成.', [bc, sf1]));
except
on e:Exception do
begin
if FileExists(fd+sf1) then DeleteFile(fd+sf1);
cxm1.Lines.Add(Format('%s 文件%s不存在.', [bc, sf1]));
end;
end;
end;
tblo.Next;
Application.ProcessMessages;
end;
cxm1.Lines.Add('文件下载结束.');
OpenDialog(s, '浏览文件', '所有文件(*.*)', '*.*', true, fd);
except
on e: Exception do
begin
cxm1.Lines.Add('连接文件服务器错误:'+e.Message);
end;
end;
finally
if Connected then Disconnect;
Free;
lst.Free;
end;