function TFrmFileManageCard.UpLoadFileBreak(SourseFileName,
我们提供的服务有:做网站、网站制作、微信公众号开发、网站优化、网站认证、南涧ssl等。为1000+企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的南涧网站制作公司
DestFileName: String): Integer;
var
upsize:int64;
IDFTP:TidFtp;
LSourceStream: TFileStream;
LSourceStreamA:TMemoryStream;
begin
Result:=-1;
if Application.MessageBox('文件上传失败,是否断点续传?','提示!',MB_YESNO)<>ID_YES then
begin
Exit;
end;
try
try
IDFTP:=TidFtp.Create(Nil);
LSourceStream := TFileStream.Create(SourseFileName, fmOpenRead or fmShareDenyNone);
IdFTP.Abort;
IdFTP.Host:=FTPHTTPControl.CUR_C_FTPSERVER;
IdFTP.Port:=FTPHTTPControl.CUR_I_FTPPORT;
IdFTP.Username:=FTPHTTPControl.CUR_C_FTPUSER;
IdFTP.Password:=FTPHTTPControl.CUR_C_FTPPWS;
IdFTP.Connect();
try
IdFTP.ChangeDir(AMShare.CurP_MMroomData.C_MMROOM_ID);
except
IdFTP.MakeDir(AMShare.CurP_MMroomData.C_MMROOM_ID);
IdFTP.ChangeDir(AMShare.CurP_MMroomData.C_MMROOM_ID);
end;
try
IdFTP.ChangeDir(Copy(ExtractFIleName(DestFileName), 1, 1));
except
IdFTP.MakeDir(Copy(ExtractFIleName(DestFileName), 1, 1));
IdFTP.ChangeDir(Copy(ExtractFIleName(DestFileName), 1, 1));
end;
try
IdFTP.ChangeDir(Copy(ExtractFIleName(DestFileName), 2, 1));
except
IdFTP.MakeDir(Copy(ExtractFIleName(DestFileName), 2, 1));
IdFTP.ChangeDir(Copy(ExtractFIleName(DestFileName), 2, 1));
end;
upsize:=IdFTP.Size(ExtractFIleName(DestFileName));
LSourceStream.Position:=upsize;
IdFTP.Passive:=True;
IdFTP.Put(SourseFileName,ExtractFIleName(DestFileName),true);
IdFTP.Disconnect;
Result:=0;
except
end;
finally
FreeANdNil(IDFTP);
FreeANdNil(LSourceStream);
end;
//如果上传失败,继续询问
if Result<>0 then
begin
//如果失败,继续断点续传
UpLoadFileBreak(SourseFileName,DestFileName);
end;
end;
本文地址:http://www.xszlo.com/article/2012-09-24/7458.html,转发请保留这个地址,谢谢
文章标题:Indy文件断点续传代码
网页网址:
http://bzwzjz.com/article/isggdd.html